use typeof instead type (#16962)
This commit is contained in:
parent
4fac8af0c9
commit
d447c0fe3f
31 changed files with 253 additions and 253 deletions
|
|
@ -147,7 +147,7 @@ proc commonType*(c: PContext; x, y: PType): PType =
|
|||
# range[0..4]. But then why is (range[0..4], 6) not range[0..6]?
|
||||
# But then why is (2,4) not range[2..4]? But I think this would break
|
||||
# too much code. So ... it's the same range or the base type. This means
|
||||
# type(if b: 0 else 1) == int and not range[0..1]. For now. In the long
|
||||
# typeof(if b: 0 else 1) == int and not range[0..1]. For now. In the long
|
||||
# run people expect ranges to work properly within a tuple.
|
||||
if not sameType(a, b):
|
||||
result = skipTypes(a, {tyRange}).skipIntLit(c.idgen)
|
||||
|
|
|
|||
|
|
@ -842,7 +842,7 @@ proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode,
|
|||
# consider: 'for x in pReturningArray()' --> we don't want the restriction
|
||||
# to 'skIterator' anymore; skIterator is preferred in sigmatch already
|
||||
# for typeof support.
|
||||
# for ``type(countup(1,3))``, see ``tests/ttoseq``.
|
||||
# for ``typeof(countup(1,3))``, see ``tests/ttoseq``.
|
||||
result = semOverloadedCall(c, n, nOrig,
|
||||
{skProc, skFunc, skMethod, skConverter, skMacro, skTemplate, skIterator}, flags)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -232,11 +232,11 @@ proc instantiateProcType(c: PContext, pt: TIdTable,
|
|||
# time adding the instantiated proc params into the current scope.
|
||||
# This is necessary, because the instantiation process may refer to
|
||||
# these params in situations like this:
|
||||
# proc foo[Container](a: Container, b: a.type.Item): type(b.x)
|
||||
# proc foo[Container](a: Container, b: a.type.Item): typeof(b.x)
|
||||
#
|
||||
# Alas, doing this here is probably not enough, because another
|
||||
# proc signature could appear in the params:
|
||||
# proc foo[T](a: proc (x: T, b: type(x.y))
|
||||
# proc foo[T](a: proc (x: T, b: typeof(x.y))
|
||||
#
|
||||
# The solution would be to move this logic into semtypinst, but
|
||||
# at this point semtypinst have to become part of sem, because it
|
||||
|
|
|
|||
|
|
@ -1346,7 +1346,7 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
|
|||
r = skipIntLit(r, c.idgen)
|
||||
if kind == skIterator:
|
||||
# see tchainediterators
|
||||
# in cases like iterator foo(it: iterator): type(it)
|
||||
# in cases like iterator foo(it: iterator): typeof(it)
|
||||
# we don't need to change the return type to iter[T]
|
||||
result.flags.incl tfIterator
|
||||
# XXX Would be nice if we could get rid of this
|
||||
|
|
@ -1704,7 +1704,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
|||
case n.kind
|
||||
of nkEmpty: result = n.typ
|
||||
of nkTypeOfExpr:
|
||||
# for ``type(countup(1,3))``, see ``tests/ttoseq``.
|
||||
# for ``typeof(countup(1,3))``, see ``tests/ttoseq``.
|
||||
checkSonsLen(n, 1, c.config)
|
||||
result = semTypeof(c, n[0], prev)
|
||||
if result.kind == tyTypeDesc: result.flags.incl tfExplicit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue