Skip to content

Report non-identifiers on the left of := - #642

Open
0z5a wants to merge 1 commit into
vtereshkov:masterfrom
0z5a:fix/564-non-name-colon-eq
Open

0z5a wants to merge 1 commit into
vtereshkov:masterfrom
0z5a:fix/564-non-name-colon-eq

Conversation

@0z5a

@0z5a 0z5a commented Nov 19, 2026

Copy link
Copy Markdown

Fixes #564.

b[0], flag := foo() is not a short variable declaration for doShortVarDeclLookahead(), so it's parsed as a designator list, and flag fails the identifier lookup. Now:

  • parseDesignatorList() checks the rest of the list with doShortVarDeclLookahead() after each comma. If an identifier list and := follow, it reports "Identifier expected on the left side of :=".
  • parseSimpleStmt() reports the same error when a designator list is followed by :=.
Statement Before After
b[0], flag := foo() Unknown identifier flag Identifier expected on the left side of :=
a, b[0] := foo() List assignment expected Identifier expected on the left side of :=
b[0] := 5 Assignment or function call expected Identifier expected on the left side of :=

flag, b[0] := foo() with an unknown flag still says "Unknown identifier flag". The first designator is parsed before anything tells us := is coming, and catching it would need a lookahead over whole expressions.

doShortVarDeclLookahead() is no longer static, so umka_expr.c can use it.

Tested on macOS with build_darwin.sh:

  • tests/negative.um: 2 new cases (the two first rows). 75 / 75 pass; without the fix the 2 new ones fail.
  • tests/all.um against expected.log: 1011 / 1011 lines OK.

b[0], flag := foo() gave "Unknown identifier flag", because it was
parsed as a designator list. Fixes vtereshkov#564.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Meaningless "Unknown identifier" error in list assignment

1 participant