0xMiden / 0xMiden/tree-sitter-masm
Grammar accepts if/else blocks with an empty then branch
- Lenguaje dominante
- JavaScript
- Estrellas
- 0
- Forks
- 1
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
`tree-sitter-masm` currently allows an `if` node whose first branch is empty as long as an `else` branch is present:
```masm
proc example
if.true
else
push.1
end
end
```
The grammar has a dedicated alternative for this shape:
```js
choice(
seq("else", field("else_body", $.block)),
seq(
field("then_body", $.block),
optional(seq("else", field("else_body", optional($.block))))
)
)
```
That means editor tooling can mark this as valid MASM even though the assembler rejects empty `if` blocks. In `0xMiden/miden-vm`, `crates/assembly/src/tests.rs` has an `empty_if` regression test that expects `begin if.true end end` to fail with:
```text
invalid syntax: expected a non-empty `if` block
```
The tree-sitter grammar should require a non-empty `then_body` before an optional `else` branch, matching the assembler syntax.
Guía de contribución
Línea de trabajo
The grammar is in the repository's main file, likely grammar.js. Look at the rule for if statements; the current choice allows an empty then_body. Modify it to require a non-empty block before the optional else. Test by building the parser and checking that the example from the issue is now invalid. The regression test in miden-vm's crates/assembly/src/tests.rs shows the expected error message.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- compilers
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Activo
- Claridad
- Bien especificado
- Aptitud para principiantes
- 75/100