Convert values to strings when assigning to a string variable
Currently, a string variable can easily be reassigned to a different type. Make it so that the value it's being reassigned to is converted to a string first. Bug: 224601891 Test: go test Change-Id: I82252cf9e106b5a3677458cf1df2e9d1dfefe0f6
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user