mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 11:07:46 +00:00
loader: make sure we always return an error even without type errors
This issue was originally reported here: https://github.com/NixOS/nixpkgs/pull/341170#issuecomment-2359237471 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!)
This commit is contained in:
+9
-1
@@ -432,7 +432,15 @@ func (p *Package) Check() error {
|
||||
if err, ok := err.(Errors); ok {
|
||||
return err
|
||||
}
|
||||
return Errors{p, typeErrors}
|
||||
if len(typeErrors) != 0 {
|
||||
// Got type errors, so return them.
|
||||
return Errors{p, typeErrors}
|
||||
}
|
||||
// This can happen in some weird cases.
|
||||
// The only case I know is when compiling a Go 1.23 program, with a
|
||||
// TinyGo version that supports Go 1.23 but is compiled using Go 1.22.
|
||||
// So this should be pretty rare.
|
||||
return Errors{p, []error{err}}
|
||||
}
|
||||
p.Pkg = typesPkg
|
||||
|
||||
|
||||
Reference in New Issue
Block a user