tact-lang / tact

Tact compiler main repository
https://tact-lang.org
MIT License
275 stars 56 forks source link

Block statements are missing from ASTs #362

Open anton-trunov opened 1 month ago

anton-trunov commented 1 month ago

Block statements are a part of the Tact grammar but those are not processed when converting Ohm.js's CSTs to ASTs.

Hence this code snippet

fun foo() {
    {
        // I'm a block statement
        let x: Int = 42;
    }
}

results in the following error message:

Missing semantic action for 'StatementBlock' in operation 'resolve_statement'. 
Action stack (most recent call last): 
  resolve_program > Program 
  resolve_program_item > default action for 'ProgramItem' 
  resolve_program_item > StaticFunction 
  resolve_declaration > default action for 'Function' 
  resolve_declaration > Function_withVoid 
  resolve_statement > default action for 'Statement' 
  resolve_statement > StatementBlock 
Gusarich commented 1 month ago

Actually they're not just missing from AST, they aren't implemented in Tact at all. I've just tried adding them but seems that handling variable scoping there isn't trivial so I suggest to move it from 1.3.1 to 1.4.0 instead.

anton-trunov commented 4 weeks ago

Agreed, let's move it to 1.4.0