Fix LSP crash and tokenizer issue

This commit is contained in:
2026-03-27 20:21:57 -07:00
parent c014233987
commit babbd01975
4 changed files with 13 additions and 3 deletions

View File

@@ -165,7 +165,8 @@ rawTokenise ts@(TS sl sc toks chars) = case chars of
doChar : Char -> List Char -> Either Error TState
doChar c cs = if elem c standalone
then rawTokenise (TS sl (sc + 1) (toks :< mktok True sl (sc + 1) Symbol (pack $ c :: Nil)) cs)
else let kind = if isDigit c then Number else if isUpper c then UIdent else Ident in
else if isDigit c then doRest (TS sl sc toks (c :: cs)) Number isDigit Lin
else let kind = if isUpper c then UIdent else Ident in
doRest (TS sl sc toks (c :: cs)) kind isIdent Lin

View File

@@ -456,8 +456,7 @@ debugLog a = putStrLn (debugStr a)
pfunc stringToInt : String Int := `(s) => {
let rval = Number(s)
if (isNaN(rval)) throw new Error(s + " is NaN")
return rval
return isNaN(rval) ? 0 : rval
}`
class Foldable (m : U U) where

9
tests/Number.newt Normal file
View File

@@ -0,0 +1,9 @@
module Number
import Prelude
add : Int Int Int
add a b = a + b
main : IO Unit
main = printLn $ add 2$ 40

1
tests/Number.newt.golden Normal file
View File

@@ -0,0 +1 @@
42