Files
Nim/tests/errmsgs/tundeclared_routine.nim
metagn fd379c2f94 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.
2024-09-27 06:23:29 +02:00

45 lines
1.3 KiB
Nim

discard """
cmd: '''nim check --hints:off $file'''
action: reject
nimout: '''
tundeclared_routine.nim(24, 17) Error: attempting to call routine: 'myiter'
found tundeclared_routine.myiter(a: string) [iterator declared in tundeclared_routine.nim(22, 12)]
found tundeclared_routine.myiter() [iterator declared in tundeclared_routine.nim(23, 12)]
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, 11) Error: undeclared identifier: 'bad5'
'''
"""
# line 20
block:
iterator myiter(a:string): int = discard
iterator myiter(): int = discard
let a = myiter(1)
block:
proc myPragma():int=discard
iterator myPragma():int=discard
proc myfun(a:int): int {.myPragma.} = 1
let a = myfun(1)
block:
type Foo = object
var a = Foo()
iterator bar3():int=discard
let a2 = a.bar3
block:
type Foo = object
var a = Foo()
let a2 = a.bar4
block:
let a = bad5(1)