lang: ast, core: fmt: Allow unification variables for fmt

This lets us pass through unification variables into the fmt function. I
hope this doesn't break anything, but it's worth trying for now.
This commit is contained in:
James Shubin
2024-08-21 18:52:24 -04:00
parent e6cb776eb6
commit da4f69cd87
2 changed files with 6 additions and 5 deletions

View File

@@ -8307,6 +8307,7 @@ func (obj *ExprCall) getPartials(fn *ExprFunc) (*types.Type, []types.Value, erro
// optimization: if type/value is already known, specify it now!
var err1, err2 error
// NOTE: This _can_ return unification variables now. Is it ok?
mapped[name], err1 = arg.Type() // nil type on error
partialValues[i], err2 = arg.Value() // nil value on error
if err1 == nil && err2 == nil && mapped[name].Cmp(partialValues[i].Type()) != nil {

View File

@@ -175,11 +175,11 @@ func (obj *PrintfFunc) FuncInfer(partialType *types.Type, partialValues []types.
continue
}
// Assume x does not contain unification variables!
if x.HasUni() {
// programming error (did the compiler change?)
return nil, nil, fmt.Errorf("programming error at arg index %d", i)
}
// NOTE: Is it okay to allow unification variables here?
//if x.HasUni() {
// // programming error (did the compiler change?)
// return nil, nil, fmt.Errorf("programming error at arg index %d", i)
//}
if err := unificationUtil.UnifyCmp(x, formatList[i-1]); err != nil {
return nil, nil, errwrap.Wrapf(err, "inconsistent type at arg index %d", i)
}