mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-07 21:43:33 +00:00
proc does not take untyped/typed as argument (#9981)
* proc does not take untyped/typed as argument * Add TODO
This commit is contained in:
committed by
Andreas Rumpf
parent
37cb5e8f53
commit
730b1b2b87
@@ -1064,6 +1064,11 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
|
||||
|
||||
if hasType:
|
||||
typ = semParamType(c, a.sons[length-2], constraint)
|
||||
var owner = getCurrOwner(c).owner
|
||||
# TODO: Disallow typed/untyped in procs in the compiler/stdlib
|
||||
if (owner.kind != skModule or owner.owner.name.s != "stdlib") and
|
||||
kind == skProc and (typ.kind == tyStmt or typ.kind == tyExpr):
|
||||
localError(c.config, a.sons[length-2].info, "'" & typ.sym.name.s & "' is only allowed in templates and macros")
|
||||
|
||||
if hasDefault:
|
||||
def = a[^1]
|
||||
|
||||
7
tests/proc/typed.nim
Normal file
7
tests/proc/typed.nim
Normal file
@@ -0,0 +1,7 @@
|
||||
discard """
|
||||
errormsg: "'typed' is only allowed in templates and macros"
|
||||
line: 6
|
||||
"""
|
||||
|
||||
proc fun(x:typed)=discard
|
||||
fun(10)
|
||||
7
tests/proc/untyped.nim
Normal file
7
tests/proc/untyped.nim
Normal file
@@ -0,0 +1,7 @@
|
||||
discard """
|
||||
errormsg: "'untyped' is only allowed in templates and macros"
|
||||
line: 6
|
||||
"""
|
||||
|
||||
proc fun(x:untyped)=discard
|
||||
fun(10)
|
||||
Reference in New Issue
Block a user