Flatten foreach calls that produce 2d lists

In make, the result of $(foreach $(x),$(y),$(foreach $(z),(w),a))
is a regular list, but in Starlark it's a list of lists. Flatten
the results of foreach expressions where each element is a list
so that they're regular lists of strings again.

Bug: 226974242
Test: go test
Change-Id: I3210d409aba0d807a5890e341ab1e0c0478f5930
This commit is contained in:
Cole Faust
2022-05-05 11:45:04 -07:00
parent 2845464d2d
commit 72374fc628
2 changed files with 18 additions and 4 deletions

View File

@@ -1574,11 +1574,21 @@ func (p *foreachCallParser) parse(ctx *parseContext, node mkparser.Node, args *m
}
}
return &foreachExpr{
var result starlarkExpr = &foreachExpr{
varName: loopVarName,
list: list,
action: action,
}
if action.typ() == starlarkTypeList {
result = &callExpr{
name: baseName + ".flatten_2d_list",
args: []starlarkExpr{result},
returnType: starlarkTypeList,
}
}
return result
}
func transformNode(node starlarkNode, transformer func(expr starlarkExpr) starlarkExpr) {