Ignore variable assignments that come after a rule definition

These private variables sometimes have references to make
variables like $< or $@. When converted to starlark, they
become invalid local variables like _< and _@, preventing
the file from being loaded even if it's never executed.

Bug: 226974242
Test: go test
Change-Id: Iafd4c6939731f3b7c051c9e41464134d5b672f23
This commit is contained in:
Cole Faust
2022-04-26 14:01:56 -07:00
parent 12097e3109
commit 00afd4f8b9
2 changed files with 4 additions and 2 deletions

View File

@@ -531,7 +531,7 @@ func (ctx *parseContext) backNode() {
func (ctx *parseContext) handleAssignment(a *mkparser.Assignment) []starlarkNode {
// Handle only simple variables
if !a.Name.Const() {
if !a.Name.Const() || a.Target != nil {
return []starlarkNode{ctx.newBadNode(a, "Only simple variables are handled")}
}
name := a.Name.Strings[0]