aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2024-10-12 10:54:22 +0200
committerAyke <[email protected]>2024-10-18 17:43:17 +0200
commit9583439be46fed7e5a782b384f65bb27788ba487 (patch)
tree738cfd58d5add3010f6ae00f976e773315cee4f4
parent2690b243ea0a47a52fd2fbaea95cdbe4e6f01bb8 (diff)
downloadtinygo-9583439be46fed7e5a782b384f65bb27788ba487.tar.gz
tinygo-9583439be46fed7e5a782b384f65bb27788ba487.zip
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!)
-rw-r--r--loader/loader.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/loader/loader.go b/loader/loader.go
index 6786ee533..f3ffa8614 100644
--- a/loader/loader.go
+++ b/loader/loader.go
@@ -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