mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-21 14:55:24 +00:00
… has no params
(cherry picked from commit abf434a336)
This commit is contained in:
@@ -1658,6 +1658,9 @@ proc semDeref(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
n[0] = a
|
||||
result = n
|
||||
var t = skipTypes(n[0].typ, {tyGenericInst, tyVar, tyLent, tyAlias, tySink, tyOwned})
|
||||
if t.kind == tyTypeDesc:
|
||||
localError(c.config, n.info, "missing generic parameter")
|
||||
return nil
|
||||
case t.kind
|
||||
of tyRef, tyPtr: n.typ() = t.elementType
|
||||
of tyMetaTypes, tyFromExpr:
|
||||
|
||||
@@ -1109,7 +1109,7 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
|
||||
let t = newTypeS(tySink, c, result)
|
||||
result = t
|
||||
else: discard
|
||||
if result.kind == tyRef and
|
||||
if result.kind == tyRef and
|
||||
c.config.selectedGC in {gcArc, gcOrc, gcAtomicArc} and
|
||||
tfTriggersCompileTime notin result.flags:
|
||||
result.flags.incl tfHasAsgn
|
||||
@@ -2176,7 +2176,8 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||
else:
|
||||
result = semTypeNode(c, whenResult, prev)
|
||||
of nkBracketExpr:
|
||||
checkMinSonsLen(n, 2, c.config)
|
||||
# Actually len >= 2 is required, but it doesn't print errors nicely with empty brackets
|
||||
checkMinSonsLen(n, 1, c.config)
|
||||
var head = n[0]
|
||||
var s = if head.kind notin nkCallKinds: semTypeIdent(c, head)
|
||||
else: symFromExpectedTypeNode(c, semExpr(c, head))
|
||||
@@ -2194,10 +2195,21 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||
incl result.flags, tfHasAsgn
|
||||
of mVarargs: result = semVarargs(c, n, prev)
|
||||
of mTypeDesc, mType, mTypeOf:
|
||||
result = makeTypeDesc(c, semTypeNode(c, n[1], nil))
|
||||
result.flags.incl tfExplicit
|
||||
if n.len != 2:
|
||||
let name = case s.magic:
|
||||
of mTypeDesc: "typedesc"
|
||||
of mType: "type"
|
||||
of mTypeOf: "typeof"
|
||||
else: ""
|
||||
localError(c.config, n.info, errXExpectsOneTypeParam % name)
|
||||
else:
|
||||
result = makeTypeDesc(c, semTypeNode(c, n[1], nil))
|
||||
result.flags.incl tfExplicit
|
||||
of mStatic:
|
||||
result = semStaticType(c, n[1], prev)
|
||||
if n.len != 2:
|
||||
localError(c.config, n.info, errXExpectsOneTypeParam % "static")
|
||||
else:
|
||||
result = semStaticType(c, n[1], prev)
|
||||
of mExpr:
|
||||
result = semTypeNode(c, n[0], nil)
|
||||
if result != nil:
|
||||
@@ -2207,9 +2219,11 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||
for i in 1..<n.len:
|
||||
result.rawAddSon(semTypeNode(c, n[i], nil))
|
||||
of mDistinct:
|
||||
checkSonsLen(n, 2, c.config)
|
||||
result = newOrPrevType(tyDistinct, prev, c)
|
||||
addSonSkipIntLit(result, semTypeNode(c, n[1], nil), c.idgen)
|
||||
of mVar:
|
||||
checkSonsLen(n, 2, c.config)
|
||||
result = newOrPrevType(tyVar, prev, c)
|
||||
var base = semTypeNode(c, n[1], nil)
|
||||
if base.kind in {tyVar, tyLent}:
|
||||
|
||||
Reference in New Issue
Block a user