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:
@@ -41,6 +41,7 @@ import (
|
||||
"github.com/purpleidea/mgmt/lang/funcs"
|
||||
"github.com/purpleidea/mgmt/lang/interfaces"
|
||||
"github.com/purpleidea/mgmt/lang/parser"
|
||||
"github.com/purpleidea/mgmt/lang/types"
|
||||
"github.com/purpleidea/mgmt/util"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
@@ -384,6 +385,9 @@ func TestInterpolateBasicStmt(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if err := resName.SetType(types.TypeStr); err != nil {
|
||||
panic("could not set type")
|
||||
}
|
||||
exp := &ast.StmtProg{
|
||||
Body: []interfaces.Stmt{
|
||||
&ast.StmtRes{
|
||||
@@ -574,6 +578,9 @@ func TestInterpolateBasicExpr(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if err := exp.SetType(types.TypeStr); err != nil {
|
||||
panic("could not set type")
|
||||
}
|
||||
testCases = append(testCases, test{
|
||||
name: "basic expansion",
|
||||
ast: xast,
|
||||
|
||||
Reference in New Issue
Block a user