Loading mk2rbc/mk2rbc.go +6 −0 Original line number Diff line number Diff line Loading @@ -566,6 +566,12 @@ func (ctx *parseContext) handleAssignment(a *mkparser.Assignment) []starlarkNode } } if asgn.lhs.valueType() == starlarkTypeString && asgn.value.typ() != starlarkTypeUnknown && asgn.value.typ() != starlarkTypeString { asgn.value = &toStringExpr{expr: asgn.value} } asgn.previous = ctx.lastAssignment(lhs) ctx.setLastAssignment(lhs, asgn) switch a.Type { Loading mk2rbc/mk2rbc_test.go +7 −3 Original line number Diff line number Diff line Loading @@ -1265,7 +1265,7 @@ TEST_VAR_LIST := foo TEST_VAR_LIST += bar TEST_VAR_2 := $(if $(TEST_VAR),bar) TEST_VAR_3 := $(if $(TEST_VAR),bar,baz) TEST_VAR_3 := $(if $(TEST_VAR),$(TEST_VAR_LIST)) TEST_VAR_4 := $(if $(TEST_VAR),$(TEST_VAR_LIST)) `, expected: `load("//build/make/core:product_config.rbc", "rblf") Loading @@ -1276,7 +1276,7 @@ def init(g, handle): g["TEST_VAR_LIST"] += ["bar"] g["TEST_VAR_2"] = ("bar" if g["TEST_VAR"] else "") g["TEST_VAR_3"] = ("bar" if g["TEST_VAR"] else "baz") g["TEST_VAR_3"] = (g["TEST_VAR_LIST"] if g["TEST_VAR"] else []) g["TEST_VAR_4"] = (g["TEST_VAR_LIST"] if g["TEST_VAR"] else []) `, }, { Loading Loading @@ -1419,6 +1419,7 @@ def init(g, handle): # Duplicated variable #RBC# type_hint list MY_VAR_2 #RBC# type_hint list my-local-var-with-dashes #RBC# type_hint string MY_STRING_VAR MY_VAR := foo MY_VAR_UNHINTED := foo Loading @@ -1431,6 +1432,8 @@ MY_VAR_2 := foo MY_VAR_4 := foo my-local-var-with-dashes := foo MY_STRING_VAR := $(wildcard foo/bar.mk) `, expected: `# Test type hints # Unsupported type Loading @@ -1448,9 +1451,10 @@ def init(g, handle): # Vars set after other statements still get the hint g["MY_VAR_2"] = ["foo"] # You can't specify a type hint after the first statement rblf.mk2rbc_error("product.mk:19", "type_hint annotations must come before the first Makefile statement") rblf.mk2rbc_error("product.mk:20", "type_hint annotations must come before the first Makefile statement") g["MY_VAR_4"] = "foo" _my_local_var_with_dashes = ["foo"] g["MY_STRING_VAR"] = " ".join(rblf.expand_wildcard("foo/bar.mk")) `, }, } Loading Loading
mk2rbc/mk2rbc.go +6 −0 Original line number Diff line number Diff line Loading @@ -566,6 +566,12 @@ func (ctx *parseContext) handleAssignment(a *mkparser.Assignment) []starlarkNode } } if asgn.lhs.valueType() == starlarkTypeString && asgn.value.typ() != starlarkTypeUnknown && asgn.value.typ() != starlarkTypeString { asgn.value = &toStringExpr{expr: asgn.value} } asgn.previous = ctx.lastAssignment(lhs) ctx.setLastAssignment(lhs, asgn) switch a.Type { Loading
mk2rbc/mk2rbc_test.go +7 −3 Original line number Diff line number Diff line Loading @@ -1265,7 +1265,7 @@ TEST_VAR_LIST := foo TEST_VAR_LIST += bar TEST_VAR_2 := $(if $(TEST_VAR),bar) TEST_VAR_3 := $(if $(TEST_VAR),bar,baz) TEST_VAR_3 := $(if $(TEST_VAR),$(TEST_VAR_LIST)) TEST_VAR_4 := $(if $(TEST_VAR),$(TEST_VAR_LIST)) `, expected: `load("//build/make/core:product_config.rbc", "rblf") Loading @@ -1276,7 +1276,7 @@ def init(g, handle): g["TEST_VAR_LIST"] += ["bar"] g["TEST_VAR_2"] = ("bar" if g["TEST_VAR"] else "") g["TEST_VAR_3"] = ("bar" if g["TEST_VAR"] else "baz") g["TEST_VAR_3"] = (g["TEST_VAR_LIST"] if g["TEST_VAR"] else []) g["TEST_VAR_4"] = (g["TEST_VAR_LIST"] if g["TEST_VAR"] else []) `, }, { Loading Loading @@ -1419,6 +1419,7 @@ def init(g, handle): # Duplicated variable #RBC# type_hint list MY_VAR_2 #RBC# type_hint list my-local-var-with-dashes #RBC# type_hint string MY_STRING_VAR MY_VAR := foo MY_VAR_UNHINTED := foo Loading @@ -1431,6 +1432,8 @@ MY_VAR_2 := foo MY_VAR_4 := foo my-local-var-with-dashes := foo MY_STRING_VAR := $(wildcard foo/bar.mk) `, expected: `# Test type hints # Unsupported type Loading @@ -1448,9 +1451,10 @@ def init(g, handle): # Vars set after other statements still get the hint g["MY_VAR_2"] = ["foo"] # You can't specify a type hint after the first statement rblf.mk2rbc_error("product.mk:19", "type_hint annotations must come before the first Makefile statement") rblf.mk2rbc_error("product.mk:20", "type_hint annotations must come before the first Makefile statement") g["MY_VAR_4"] = "foo" _my_local_var_with_dashes = ["foo"] g["MY_STRING_VAR"] = " ".join(rblf.expand_wildcard("foo/bar.mk")) `, }, } Loading