Skip to content

Commit 652acf9

Browse files
committed
loader: make sure we always return an error even without type errors
This issue was originally reported here: NixOS/nixpkgs#341170 (comment) The fix here isn't a great fix, it turns the error message from this: # runtime/interrupt into this: # runtime/interrupt package requires newer Go version go1.23 ...so not great, because it doesn't show the real error message (which is that TinyGo wasn't compiled with the right Go version). But at least it gives a hint in the right direction. It's difficult to test for this specific case, so I've left out testing in this case (boo!)
1 parent e27a297 commit 652acf9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

loader/loader.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,15 @@ func (p *Package) Check() error {
432432
if err, ok := err.(Errors); ok {
433433
return err
434434
}
435-
return Errors{p, typeErrors}
435+
if len(typeErrors) != 0 {
436+
// Got type errors, so return them.
437+
return Errors{p, typeErrors}
438+
}
439+
// This can happen in some weird cases.
440+
// The only case I know is when compiling a Go 1.23 program, with a
441+
// TinyGo version that supports Go 1.23 but is compiled using Go 1.22.
442+
// So this should be pretty rare.
443+
return Errors{p, []error{err}}
436444
}
437445
p.Pkg = typesPkg
438446

0 commit comments

Comments
 (0)