Repository navigation
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #564.
b[0], flag := foo()is not a short variable declaration fordoShortVarDeclLookahead(), so it's parsed as a designator list, andflagfails the identifier lookup. Now:parseDesignatorList()checks the rest of the list withdoShortVarDeclLookahead()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:=.b[0], flag := foo()a, b[0] := foo()b[0] := 5flag, b[0] := foo()with an unknownflagstill 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, soumka_expr.ccan 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.umagainstexpected.log: 1011 / 1011 lines OK.