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

Robust parsing of foo. with error node #1560

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions source/parser.hera
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,18 @@ PropertyAccess
children: [ dot, ...comments, ...id.children ],
}

# NOTE: For LSP completion / robustness, parse `foo.` but with an error node
ExplicitAccessStart:dot &EOS ->
return {
type: "PropertyAccess",
name: "",
dot,
children: [ dot, {
type: "Error",
message: "Missing property name after '.'",
}]
}

ImplicitAccessStart:dot ( PrivateIdentifier / LengthShorthand ):id ->
return {
type: "PropertyAccess",
Expand Down
Loading