Skip to content

Local const declarations inside method bodies are not parsed correctly #21

Description

@dreed-sd

GDScript supports const declarations inside method bodies (local constants), but the parser doesn't recognize const as a statement-level keyword. This causes const NAME := value to be split into multiple expression statements instead of a single GDVariableDeclarationStatement.

  func join() -> String:
      const SEP := " | "
      return "a" + SEP + "b"

Iterating method.AllNodes, the const SEP := " | " line produces three separate nodes instead of one GDVariableDeclarationStatement:

GDExpressionStatement: const
GDExpressionStatement: SEP
GDExpressionStatement: " | "

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions