diff --git a/lang/ast/structs.go b/lang/ast/structs.go index c0775eb3be..171e150713 100644 --- a/lang/ast/structs.go +++ b/lang/ast/structs.go @@ -8682,7 +8682,7 @@ func (obj *ExprParam) SetValue(value types.Value) error { // usually only be valid once the engine has run and values have been produced. // This might get called speculatively (early) during unification to learn more. func (obj *ExprParam) Value() (types.Value, error) { - return nil, nil + return nil, fmt.Errorf("no value for ExprParam") } // ExprPoly is a polymorphic expression that is a definition that can be used in @@ -8799,7 +8799,7 @@ func (obj *ExprPoly) SetValue(value types.Value) error { // usually only be valid once the engine has run and values have been produced. // This might get called speculatively (early) during unification to learn more. func (obj *ExprPoly) Value() (types.Value, error) { - return nil, nil + return nil, fmt.Errorf("no value for ExprPoly") } // ExprIf represents an if expression which *must* have both branches, and which diff --git a/lang/interpret_test/TestAstFunc2/scope-lambda-printf.txtar b/lang/interpret_test/TestAstFunc2/scope-lambda-printf.txtar new file mode 100644 index 0000000000..434d79dd63 --- /dev/null +++ b/lang/interpret_test/TestAstFunc2/scope-lambda-printf.txtar @@ -0,0 +1,12 @@ +-- main.mcl -- +import "fmt" +$format = "%d" # should get ignored +$fn = func($format) { + fmt.printf($format, 42) +} +test $fn("%s") {} +# should error at unification if possible, otherwise at runtime +# TODO: I would expect that if the "%s" and "%d" swapped, that speculatively we +# would be able to run this at compile time and know the result statically. +-- OUTPUT -- +# err: errStream: func `printf@??????????` stopped before it was loaded: base kind does not match (Str != Int)