* fix #16898
* fix #17621

* Update compiler/semtypes.nim
This commit is contained in:
flywind 2021-04-07 00:01:54 +08:00 • committed by GitHub
commit e406e28738
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 3 deletions

View file

@ -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: