mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-04 02:44:44 +00:00
fix nimsuggest crash with arrow type sugar (#24185)
fixes #24179 The original fix made it so calls to `skError`/`skUnknown` (in this case `->`, for some reason `sugar` couldn't be imported) returned an error node, however this breaks tsug_accquote for some reason I don't understand (it even parses as `tsug_accquote.discard`) so I've just added a guard based on the stacktrace.
This commit is contained in:
@@ -890,6 +890,9 @@ proc analyseIfAddressTaken(c: PContext, n: PNode, isOutParam: bool): PNode =
|
||||
|
||||
proc analyseIfAddressTakenInCall(c: PContext, n: PNode, isConverter = false) =
|
||||
checkMinSonsLen(n, 1, c.config)
|
||||
if n[0].typ == nil:
|
||||
# n[0] might be erroring node in nimsuggest
|
||||
return
|
||||
const
|
||||
FakeVarParams = {mNew, mNewFinalize, mInc, ast.mDec, mIncl, mExcl,
|
||||
mSetLengthStr, mSetLengthSeq, mAppendStrCh, mAppendStrStr, mSwap,
|
||||
|
||||
20
nimsuggest/tests/tarrowcrash.nim
Normal file
20
nimsuggest/tests/tarrowcrash.nim
Normal file
@@ -0,0 +1,20 @@
|
||||
# issue #24179
|
||||
|
||||
import sugar
|
||||
|
||||
type
|
||||
Parser[T] = object
|
||||
|
||||
proc eatWhile[T](p: Parser[T], predicate: T -> bool): seq[T] =
|
||||
return @[]
|
||||
|
||||
proc skipWs(p: Parser[char]) =
|
||||
discard p.eatWhile((c: char) => c == 'a')
|
||||
#[!]#
|
||||
|
||||
discard """
|
||||
$nimsuggest --tester $file
|
||||
>chk $1
|
||||
chk;;skUnknown;;;;Hint;;???;;0;;-1;;">> (toplevel): import(dirty): tests/tarrowcrash.nim [Processing]";;0
|
||||
chk;;skUnknown;;;;Hint;;$file;;11;;5;;"\'skipWs\' is declared but not used [XDeclaredButNotUsed]";;0
|
||||
"""
|
||||
@@ -9,7 +9,7 @@ tundeclared_routine.nim(29, 28) Error: invalid pragma: myPragma
|
||||
tundeclared_routine.nim(36, 13) Error: undeclared field: 'bar3' for type tundeclared_routine.Foo [type declared in tundeclared_routine.nim(33, 8)]
|
||||
found tundeclared_routine.bar3() [iterator declared in tundeclared_routine.nim(35, 12)]
|
||||
tundeclared_routine.nim(41, 13) Error: undeclared field: 'bar4' for type tundeclared_routine.Foo [type declared in tundeclared_routine.nim(39, 8)]
|
||||
tundeclared_routine.nim(44, 15) Error: attempting to call routine: 'bad5'
|
||||
tundeclared_routine.nim(44, 11) Error: undeclared identifier: 'bad5'
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user