Fix couple of linting problems

This commit is contained in:
Sameer Rahmani 2021-01-15 20:48:56 +00:00
parent 2d7a32bcf3
commit 3904d6ef74
3 changed files with 6 additions and 5 deletions

View File

@ -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

View File

@ -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)
}

View File

@ -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 {