Compiler has bug() to wrap unexpected errors

This commit is contained in:
Sasha Koshka 2024-02-27 02:45:32 -05:00
parent d5bb1be894
commit 5e740ebf5f
2 changed files with 12 additions and 1 deletions

View File

@ -24,7 +24,7 @@ func (this *Compiler) CompileUnit (address entity.Address) error {
irModule, err := native.NativeTarget().Generate(semanticTree)
if err != nil {
return errors.New(fmt.Sprintf("internal errror: %v", err))
return this.bug(err)
}
// if the format isn't specified, try to get it from the filename

View File

@ -23,6 +23,17 @@ type Compiler struct {
Format string
}
func (this *Compiler) bug (err error) error {
return errors.New(fmt.Sprintln (
"Bug detected in the compiler!\n" +
"The FSPL compiler has experienced an error that should not",
"happen.\n" +
"Please submit a report with this info and the code you were",
"compiling to:",
"https://git.tebibyte.media/sashakoshka/fspl/issues\n" +
"The error is:", err))
}
func (this *Compiler) AnalyzeUnit (
semanticTree *analyzer.Tree,
path string,