Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misplaced Block AST due to syntax error #381

Open
simerplaha opened this issue Feb 18, 2025 · 0 comments
Open

Misplaced Block AST due to syntax error #381

simerplaha opened this issue Feb 18, 2025 · 0 comments
Labels
area:soft-parser SoftParser type:enhancement Enhances an existing feature by extending its functionality

Comments

@simerplaha
Copy link
Member

simerplaha commented Feb 18, 2025

Overview

fn (param: -> {
    param

The above code has following missing syntax:

  • Function name
  • Param Type
  • Closing paren
  • Return type
  • Closing brace

It will still produce the correct go-to-definition results:

fn (>>param<<: -> {
  para@@m

And the Block still gets parsed as expected, i.e., as a child of the Function's AST:

  • Body
    • Function
      • FunctionSignature
      • Block

Issue

fn (param: - {
    param

An error in the return signature -> (removed >) causes the Block to be parsed as a sibling of the Function AST.

  • Body
    • Function
      • FunctionSignature
    • Block

This means that the Block is no longer within the scope of the Function, causing the function parameter param inaccessible to the Block.

Expected

The first occurring Block should always be parsed a child of the parent expecting a block (while, for etc), for all syntax errors. The parent in this case is the Function AST.

@simerplaha simerplaha added the area:soft-parser SoftParser label Feb 18, 2025
@simerplaha simerplaha changed the title Always parse Block as child Misplaced Block AST due to return type syntax error Feb 18, 2025
@simerplaha simerplaha changed the title Misplaced Block AST due to return type syntax error Misplaced Block AST due to syntax error Feb 18, 2025
@simerplaha simerplaha added the type:enhancement Enhances an existing feature by extending its functionality label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:soft-parser SoftParser type:enhancement Enhances an existing feature by extending its functionality
Projects
None yet
Development

No branches or pull requests

1 participant