From e6cb776eb671f40b3587d36708c02642f2213f67 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Wed, 21 Aug 2024 18:50:11 -0400 Subject: [PATCH] lang: ast, core: fmt: Catch invalid nil signatures We accidentally had a bad error triggered. --- lang/ast/structs.go | 4 ++++ lang/core/fmt/printf_func.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lang/ast/structs.go b/lang/ast/structs.go index 9a42c0d1..72969ec0 100644 --- a/lang/ast/structs.go +++ b/lang/ast/structs.go @@ -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. diff --git a/lang/core/fmt/printf_func.go b/lang/core/fmt/printf_func.go index 7ef76d90..c1842c02 100644 --- a/lang/core/fmt/printf_func.go +++ b/lang/core/fmt/printf_func.go @@ -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)