diff options
author | Ayke van Laethem <[email protected]> | 2020-03-23 14:40:38 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2020-03-24 15:07:55 +0100 |
commit | 26aba727296c7302cf369d2b6e32b4fe010e1434 (patch) | |
tree | a7060c4a27f7d96ea8429fc43b6a59fcd791ec22 /transform/optimizer.go | |
parent | 25fcf3e18e3baf6496dddba0a3f8811b2ca90609 (diff) | |
download | tinygo-26aba727296c7302cf369d2b6e32b4fe010e1434.tar.gz tinygo-26aba727296c7302cf369d2b6e32b4fe010e1434.zip |
transform: replace panics with source locations
Panics are bad for usability: whenever something breaks, the user is
shown a (not very informative) backtrace. Replace it with real error
messages instead, that even try to display the Go source location.
Diffstat (limited to 'transform/optimizer.go')
-rw-r--r-- | transform/optimizer.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/transform/optimizer.go b/transform/optimizer.go index 71bf4d617..2677e6902 100644 --- a/transform/optimizer.go +++ b/transform/optimizer.go @@ -75,7 +75,10 @@ func Optimize(mod llvm.Module, config *compileopts.Config, optLevel, sizeLevel i OptimizeMaps(mod) OptimizeStringToBytes(mod) OptimizeAllocs(mod) - LowerInterfaces(mod) + err := LowerInterfaces(mod) + if err != nil { + return []error{err} + } errs := LowerInterrupts(mod) if len(errs) > 0 { @@ -115,7 +118,10 @@ func Optimize(mod llvm.Module, config *compileopts.Config, optLevel, sizeLevel i } else { // Must be run at any optimization level. - LowerInterfaces(mod) + err := LowerInterfaces(mod) + if err != nil { + return []error{err} + } if config.FuncImplementation() == compileopts.FuncValueSwitch { LowerFuncValues(mod) } |