lang: ast: Ensure a list doesn't sneak through type interpolation

If we had a single list wrapped in an interpolated string, it could
sneak through type unification, which is not correct. Wrapping a
variable by interpolation in a string, must force it to be a string.
This commit is contained in:
James Shubin
2024-03-20 18:06:29 -04:00
parent 340a832884
commit 946468dc99
8 changed files with 81 additions and 0 deletions

View File

@@ -5408,6 +5408,10 @@ func (obj *ExprStr) Interpolate() (interfaces.Expr, error) {
}, nil
}
// we got something, overwrite the existing static str
// ensure str, to avoid a pass-through list in a simple interpolation
if err := result.SetType(types.TypeStr); err != nil {
return nil, errwrap.Wrapf(err, "interpolated string expected a different type")
}
return result, nil // replacement
}