@@ -269,6 +269,8 @@ proc semRangeAux(c: PContext, n: PNode, prev: PType): PType =
269
269
localError (c.config, n.info, " range is empty" )
270
270
271
271
var range : array [2 , PNode ]
272
+ # XXX this is still a hard compilation in a generic context, this can
273
+ # result in unresolved generic parameters being treated like real types
272
274
range [0 ] = semExprWithType (c, n[1 ], {efDetermineType})
273
275
range [1 ] = semExprWithType (c, n[2 ], {efDetermineType})
274
276
@@ -277,7 +279,7 @@ proc semRangeAux(c: PContext, n: PNode, prev: PType): PType =
277
279
rangeT[i] = range [i].typ.skipTypes ({tyStatic}).skipIntLit (c.idgen)
278
280
279
281
let hasUnknownTypes = c.inGenericContext > 0 and
280
- rangeT[0 ].kind == tyFromExpr or rangeT[1 ].kind == tyFromExpr
282
+ ( rangeT[0 ].kind == tyFromExpr or rangeT[1 ].kind == tyFromExpr)
281
283
282
284
if not hasUnknownTypes:
283
285
if not sameType (rangeT[0 ].skipTypes ({tyRange}), rangeT[1 ].skipTypes ({tyRange})):
@@ -337,6 +339,8 @@ proc semArrayIndex(c: PContext, n: PNode): PType =
337
339
elif n.kind == nkInfix and n[0 ].kind == nkIdent and n[0 ].ident.s == " ..<" :
338
340
result = errorType (c)
339
341
else :
342
+ # XXX this is still a hard compilation in a generic context, this can
343
+ # result in unresolved generic parameters being treated like real types
340
344
let e = semExprWithType (c, n, {efDetermineType})
341
345
if e.typ.kind == tyFromExpr:
342
346
result = makeRangeWithStaticExpr (c, e.typ.n)
@@ -357,7 +361,7 @@ proc semArrayIndex(c: PContext, n: PNode): PType =
357
361
if not isOrdinalType (e.typ.skipTypes ({tyStatic, tyAlias, tyGenericInst, tySink})):
358
362
localError (c.config, n[1 ].info, errOrdinalTypeExpected % typeToString (e.typ, preferDesc))
359
363
# This is an int returning call, depending on an
360
- # yet unknown generic param (see tgenericshardcases ).
364
+ # yet unknown generic param (see tuninstantiatedgenericcalls ).
361
365
# We are going to construct a range type that will be
362
366
# properly filled-out in semtypinst (see how tyStaticExpr
363
367
# is handled there).
@@ -380,7 +384,8 @@ proc semArray(c: PContext, n: PNode, prev: PType): PType =
380
384
let indx = semArrayIndex (c, n[1 ])
381
385
var indxB = indx
382
386
if indxB.kind in {tyGenericInst, tyAlias, tySink}: indxB = lastSon (indxB)
383
- if indxB.kind notin {tyGenericParam, tyStatic, tyFromExpr}:
387
+ if indxB.kind notin {tyGenericParam, tyStatic, tyFromExpr} and
388
+ tfUnresolved notin indxB.flags:
384
389
if indxB.skipTypes ({tyRange}).kind in {tyUInt, tyUInt64}:
385
390
discard
386
391
elif not isOrdinalType (indxB):
@@ -737,7 +742,13 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
737
742
if e.kind != nkIntLit: discard " don't report followup error"
738
743
elif e.intVal != 0 and branch == nil : branch = it[1 ]
739
744
else :
740
- it[0 ] = forceBool (c, semExprWithType (c, it[0 ]))
745
+ # XXX this is still a hard compilation in a generic context, this can
746
+ # result in unresolved generic parameters being treated like real types
747
+ let e = semExprWithType (c, it[0 ], {efDetermineType})
748
+ if e.typ.kind == tyFromExpr:
749
+ it[0 ] = makeStaticExpr (c, e)
750
+ else :
751
+ it[0 ] = forceBool (c, e)
741
752
of nkElse:
742
753
checkSonsLen (it, 1 , c.config)
743
754
if branch == nil : branch = it[0 ]
0 commit comments