mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-01 10:52:14 +00:00
fixes for the new overloading resolution
This commit is contained in:
@@ -1526,8 +1526,9 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||
of mNewFinalize: genNewFinalize(p, e)
|
||||
of mNewSeq: genNewSeq(p, e)
|
||||
of mSizeOf:
|
||||
let t = e.sons[1].typ.skipTypes({tyTypeDesc})
|
||||
putIntoDest(p, d, e.typ, ropef("((NI)sizeof($1))",
|
||||
[getTypeDesc(p.module, e.sons[1].typ)]))
|
||||
[getTypeDesc(p.module, t)]))
|
||||
of mChr: genCast(p, e, d)
|
||||
of mOrd: genOrd(p, e, d)
|
||||
of mLengthArray, mHigh, mLengthStr, mLengthSeq, mLengthOpenArray:
|
||||
|
||||
@@ -86,10 +86,9 @@ proc GetUniqueType*(key: PType): PType =
|
||||
if result == nil:
|
||||
gCanonicalTypes[k] = key
|
||||
result = key
|
||||
of tyGenericParam, tyTypeClass:
|
||||
of tyGenericParam, tyTypeClass, tyTypeDesc:
|
||||
InternalError("GetUniqueType")
|
||||
of tyGenericInst, tyDistinct, tyOrdinal, tyMutable, tyConst, tyIter,
|
||||
tyTypeDesc:
|
||||
of tyGenericInst, tyDistinct, tyOrdinal, tyMutable, tyConst, tyIter:
|
||||
result = GetUniqueType(lastSon(key))
|
||||
of tyArrayConstr, tyGenericInvokation, tyGenericBody,
|
||||
tyOpenArray, tyArray, tySet, tyRange, tyTuple,
|
||||
|
||||
@@ -10,18 +10,6 @@
|
||||
# this module does the semantic checking for expressions
|
||||
# included from sem.nim
|
||||
|
||||
proc restoreOldStyleType(n: PNode) =
|
||||
# semExprWithType used to return the same type
|
||||
# for nodes such as (100) or (int).
|
||||
# This is inappropriate. The type of the first expression
|
||||
# should be "int", while the type of the second one should
|
||||
# be typedesc(int).
|
||||
#
|
||||
# This is strictly for backward compatibility until
|
||||
# the transition to types as first-class values is complete.
|
||||
if n.typ.kind == tyTypeDesc and n.typ.sonsLen == 1:
|
||||
n.typ = n.typ.sons[0]
|
||||
|
||||
proc semTemplateExpr(c: PContext, n: PNode, s: PSym, semCheck = true): PNode =
|
||||
markUsed(n, s)
|
||||
pushInfoContext(n.info)
|
||||
|
||||
@@ -30,6 +30,11 @@ proc getIdentNode(n: PNode): PNode =
|
||||
else:
|
||||
illFormedAst(n)
|
||||
result = n
|
||||
|
||||
proc newSymNodeTypeDesc(s: PSym; info: TLineInfo): PNode =
|
||||
result = newSymNode(s, info)
|
||||
result.typ = newType(tyTypeDesc, s.owner)
|
||||
result.typ.addSonSkipIntLit(s.typ)
|
||||
|
||||
proc semGenericStmt(c: PContext, n: PNode, flags: TSemGenericFlags,
|
||||
ctx: var TIntSet): PNode
|
||||
@@ -63,12 +68,12 @@ proc semGenericStmtSymbol(c: PContext, n: PNode, s: PSym): PNode =
|
||||
else:
|
||||
result = symChoice(c, n, s, scOpen)
|
||||
of skGenericParam:
|
||||
result = newSymNode(s, n.info)
|
||||
result = newSymNodeTypeDesc(s, n.info)
|
||||
of skParam:
|
||||
result = n
|
||||
of skType:
|
||||
if (s.typ != nil) and (s.typ.kind != tyGenericParam):
|
||||
result = newSymNode(s, n.info)
|
||||
result = newSymNodeTypeDesc(s, n.info)
|
||||
else:
|
||||
result = n
|
||||
else: result = newSymNode(s, n.info)
|
||||
@@ -156,13 +161,13 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||
of skProc, skMethod, skIterator, skConverter:
|
||||
result.sons[0] = symChoice(c, n.sons[0], s, scOption)
|
||||
first = 1
|
||||
of skGenericParam:
|
||||
result.sons[0] = newSymNode(s, n.sons[0].info)
|
||||
of skGenericParam:
|
||||
result.sons[0] = newSymNodeTypeDesc(s, n.sons[0].info)
|
||||
first = 1
|
||||
of skType:
|
||||
# bad hack for generics:
|
||||
if (s.typ != nil) and (s.typ.kind != tyGenericParam):
|
||||
result.sons[0] = newSymNode(s, n.sons[0].info)
|
||||
result.sons[0] = newSymNodeTypeDesc(s, n.sons[0].info)
|
||||
first = 1
|
||||
else:
|
||||
result.sons[0] = newSymNode(s, n.sons[0].info)
|
||||
|
||||
Reference in New Issue
Block a user