mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-21 23:05:27 +00:00
fixes #8671; show helpful msg (lookup symbol, eg iterator) on 'attempting to call undeclared routine' error (#8786)
This commit is contained in:
committed by
Andreas Rumpf
parent
8232bd04f9
commit
eb946f37a7
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
line: 7
|
||||
errormsg: "attempting to call undeclared routine: 'items'"
|
||||
errormsg: "attempting to call routine: 'items'"
|
||||
"""
|
||||
|
||||
type a = enum b,c,d
|
||||
|
||||
13
tests/errmsgs/undeclared_routime.nim
Normal file
13
tests/errmsgs/undeclared_routime.nim
Normal file
@@ -0,0 +1,13 @@
|
||||
discard """
|
||||
cmd: '''nim c --hints:off $file'''
|
||||
errormsg: "attempting to call routine: 'myiter'"
|
||||
nimout: '''undeclared_routime.nim(13, 15) Error: attempting to call routine: 'myiter'
|
||||
found 'undeclared_routime.myiter(a: string)[declared in undeclared_routime.nim(10, 9)]' of kind 'iterator'
|
||||
found 'undeclared_routime.myiter()[declared in undeclared_routime.nim(11, 9)]' of kind 'iterator'
|
||||
'''
|
||||
"""
|
||||
|
||||
iterator myiter(a:string): int = discard
|
||||
iterator myiter(): int = discard
|
||||
|
||||
let a = myiter(1)
|
||||
9
tests/errmsgs/undeclared_routime2.nim
Normal file
9
tests/errmsgs/undeclared_routime2.nim
Normal file
@@ -0,0 +1,9 @@
|
||||
discard """
|
||||
cmd: '''nim c --hints:off $file'''
|
||||
errormsg: "invalid pragma: myPragma"
|
||||
"""
|
||||
|
||||
proc myPragma():int=discard
|
||||
iterator myPragma():int=discard
|
||||
proc myfun(a:int): int {.myPragma.} = 1
|
||||
let a = myfun(1)
|
||||
13
tests/errmsgs/undeclared_routime3.nim
Normal file
13
tests/errmsgs/undeclared_routime3.nim
Normal file
@@ -0,0 +1,13 @@
|
||||
discard """
|
||||
cmd: '''nim c --hints:off $file'''
|
||||
errormsg: "undeclared field: 'bar'"
|
||||
nimout: '''undeclared_routime3.nim(13, 10) Error: undeclared field: 'bar'
|
||||
found 'undeclared_routime3.bar()[declared in undeclared_routime3.nim(12, 9)]' of kind 'iterator'
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
type Foo = object
|
||||
var a = Foo()
|
||||
iterator bar():int=discard
|
||||
let a = a.bar
|
||||
10
tests/errmsgs/undeclared_routime4.nim
Normal file
10
tests/errmsgs/undeclared_routime4.nim
Normal file
@@ -0,0 +1,10 @@
|
||||
discard """
|
||||
cmd: '''nim c --hints:off $file'''
|
||||
errormsg: "undeclared field: 'bar'"
|
||||
nimout: '''undeclared_routime4.nim(10, 10) Error: undeclared field: 'bar'
|
||||
'''
|
||||
"""
|
||||
|
||||
type Foo = object
|
||||
var a = Foo()
|
||||
let a = a.bar
|
||||
9
tests/errmsgs/undeclared_routime5.nim
Normal file
9
tests/errmsgs/undeclared_routime5.nim
Normal file
@@ -0,0 +1,9 @@
|
||||
discard """
|
||||
cmd: '''nim c --hints:off $file'''
|
||||
errormsg: "undeclared identifier: 'myfun'"
|
||||
nimout: '''undeclared_routime5.nim(9, 9) Error: undeclared identifier: 'myfun'
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
let a = myfun(1)
|
||||
11
tests/errmsgs/undeclared_routime_compiles.nim
Normal file
11
tests/errmsgs/undeclared_routime_compiles.nim
Normal file
@@ -0,0 +1,11 @@
|
||||
# D20180828T234921:here
|
||||
template foo*(iter: untyped): untyped =
|
||||
when compiles(iter.unexistingField): 0
|
||||
elif compiles(iter.len): 1
|
||||
else: 2
|
||||
|
||||
proc foo[A]()=
|
||||
let a2 = @[10, 11]
|
||||
let a3 = foo(pairs(a2))
|
||||
|
||||
foo[int]()
|
||||
@@ -1,7 +1,7 @@
|
||||
discard """
|
||||
file: "tissue710.nim"
|
||||
line: 8
|
||||
errorMsg: "attempting to call undeclared routine: '||'"
|
||||
errorMsg: "attempting to call routine: '||'"
|
||||
"""
|
||||
var sum = 0
|
||||
for x in 3..1000:
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
discard """
|
||||
nimout: '''
|
||||
found 'a' of kind 'var''''
|
||||
file: "tnoop.nim"
|
||||
line: 11
|
||||
errormsg: "attempting to call undeclared routine: 'a'"
|
||||
line: 12
|
||||
errormsg: "attempting to call routine: 'a'"
|
||||
"""
|
||||
|
||||
|
||||
var
|
||||
a: int
|
||||
|
||||
|
||||
Reference in New Issue
Block a user