diff --git a/bootstrap/pkg/ast/source.go b/bootstrap/pkg/ast/source.go index 1b72be4..cef2b98 100644 --- a/bootstrap/pkg/ast/source.go +++ b/bootstrap/pkg/ast/source.go @@ -27,6 +27,7 @@ import ( ) var builtinSource *Source +var OutOfRangeLine string = "----" type Source struct { // A Pointer to the buffer where the parser used for parsing the source @@ -59,7 +60,7 @@ func (s *Source) GetLine(linenum int) string { if linenum > 0 && linenum <= len(lines) { return lines[linenum-1] } - return "----" + return OutOfRangeLine } // LineNumberFor returns the line number associated with the given position `pos` in diff --git a/bootstrap/pkg/core/core.go b/bootstrap/pkg/core/core.go index de714ea..76fefba 100644 --- a/bootstrap/pkg/core/core.go +++ b/bootstrap/pkg/core/core.go @@ -78,10 +78,11 @@ func REPL(flags map[string]bool) { EOFPrompt: "exit", HistorySearchFold: true, }) + if err != nil { panic(err) - } + rl.HistoryEnable() defer rl.Close() @@ -108,7 +109,6 @@ for details take a look at the LICENSE file. } rep(rt, line) } - } func Run(flags map[string]bool, args []string) { @@ -121,7 +121,6 @@ func Run(flags map[string]bool, args []string) { rt.CreateNS("serene.internal", "RUN", true) if len(args) == 0 { - PrintError(rt, MakePlainError("'run' command needs at least one argument")) os.Exit(1) } diff --git a/bootstrap/pkg/core/printer.go b/bootstrap/pkg/core/printer.go index da45078..bdd1320 100644 --- a/bootstrap/pkg/core/printer.go +++ b/bootstrap/pkg/core/printer.go @@ -23,6 +23,7 @@ import ( "strings" "github.com/gookit/color" + "serene-lang.org/bootstrap/pkg/ast" "serene-lang.org/bootstrap/pkg/errors" ) @@ -149,7 +150,7 @@ func frameSource(traces *TraceBack, frameIndex int) string { if fLoc.IsKnownLocaiton() { line := fLoc.GetSource().GetLine(i) - if line != "----" { + if line != ast.OutOfRangeLine { lines += fmt.Sprintf("%d:\t%s\n", i, line) } } else {