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 builtinSource *Source
var OutOfRangeLine string = "----"
type Source struct { type Source struct {
// A Pointer to the buffer where the parser used for parsing the source // 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) { if linenum > 0 && linenum <= len(lines) {
return lines[linenum-1] return lines[linenum-1]
} }
return "----" return OutOfRangeLine
} }
// LineNumberFor returns the line number associated with the given position `pos` in // 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", EOFPrompt: "exit",
HistorySearchFold: true, HistorySearchFold: true,
}) })
if err != nil { if err != nil {
panic(err) panic(err)
} }
rl.HistoryEnable() rl.HistoryEnable()
defer rl.Close() defer rl.Close()
@ -108,7 +109,6 @@ for details take a look at the LICENSE file.
} }
rep(rt, line) rep(rt, line)
} }
} }
func Run(flags map[string]bool, args []string) { 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) rt.CreateNS("serene.internal", "RUN", true)
if len(args) == 0 { if len(args) == 0 {
PrintError(rt, MakePlainError("'run' command needs at least one argument")) PrintError(rt, MakePlainError("'run' command needs at least one argument"))
os.Exit(1) os.Exit(1)
} }

View File

@ -23,6 +23,7 @@ import (
"strings" "strings"
"github.com/gookit/color" "github.com/gookit/color"
"serene-lang.org/bootstrap/pkg/ast"
"serene-lang.org/bootstrap/pkg/errors" "serene-lang.org/bootstrap/pkg/errors"
) )
@ -149,7 +150,7 @@ func frameSource(traces *TraceBack, frameIndex int) string {
if fLoc.IsKnownLocaiton() { if fLoc.IsKnownLocaiton() {
line := fLoc.GetSource().GetLine(i) line := fLoc.GetSource().GetLine(i)
if line != "----" { if line != ast.OutOfRangeLine {
lines += fmt.Sprintf("%d:\t%s\n", i, line) lines += fmt.Sprintf("%d:\t%s\n", i, line)
} }
} else { } else {