lang: ast, core: fmt: Catch invalid nil signatures

We accidentally had a bad error triggered.
This commit is contained in:
James Shubin
2024-08-21 18:50:11 -04:00
parent 7557114b4e
commit e6cb776eb6
2 changed files with 5 additions and 1 deletions

View File

@@ -8474,6 +8474,10 @@ func (obj *ExprCall) Infer() (*types.Type, []*interfaces.UnificationInvariant, e
return nil, nil, errwrap.Wrapf(err, "func `%s` infer error", exprFunc.Title)
}
invariants = append(invariants, invars...)
if typ == nil { // should get a sig, not a nil!
// programming error
return nil, nil, fmt.Errorf("func `%s` infer type was nil", exprFunc.Title)
}
// It's important that we copy the type signature here.
// See the above comment which explains the reasoning.

View File

@@ -178,7 +178,7 @@ func (obj *PrintfFunc) FuncInfer(partialType *types.Type, partialValues []types.
// Assume x does not contain unification variables!
if x.HasUni() {
// programming error (did the compiler change?)
return nil, nil, errwrap.Wrapf(err, "programming error at arg index %d", i)
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)