parent
c7b4639460
commit
e406e28738
4 changed files with 52 additions and 3 deletions
|
|
@ -10,7 +10,7 @@
|
|||
# this module does the semantic checking of type declarations
|
||||
# included from sem.nim
|
||||
|
||||
import math
|
||||
import std/math
|
||||
|
||||
const
|
||||
errStringOrIdentNodeExpected = "string or ident node expected"
|
||||
|
|
@ -1171,6 +1171,7 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
|
|||
else: discard
|
||||
|
||||
proc semParamType(c: PContext, n: PNode, constraint: var PNode): PType =
|
||||
## Semchecks the type of parameters.
|
||||
if n.kind == nkCurlyExpr:
|
||||
result = semTypeNode(c, n[0], nil)
|
||||
constraint = semNodeKindConstraints(n, c.config, 1)
|
||||
|
|
@ -1226,10 +1227,11 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
|
|||
if hasType:
|
||||
typ = semParamType(c, a[^2], constraint)
|
||||
# TODO: Disallow typed/untyped in procs in the compiler/stdlib
|
||||
if kind == skProc and (typ.kind == tyTyped or typ.kind == tyUntyped):
|
||||
if kind in {skProc, skFunc} and (typ.kind == tyTyped or typ.kind == tyUntyped):
|
||||
if not isMagic(getCurrOwner(c)):
|
||||
localError(c.config, a[^2].info, "'" & typ.sym.name.s & "' is only allowed in templates and macros or magic procs")
|
||||
|
||||
|
||||
if hasDefault:
|
||||
def = a[^1]
|
||||
block determineType:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue