adds another fix for concept in JS (#23535)

ref https://github.com/nim-lang/Nim/issues/9550
This commit is contained in:
ringabout
2024-04-24 23:33:58 +08:00
committed by GitHub
parent cd3cf3a20e
commit a5c1a6f042
2 changed files with 13 additions and 5 deletions

View File

@@ -1456,7 +1456,7 @@ proc genArrayAddr(p: PProc, n: PNode, r: var TCompRes) =
r.kind = resExpr
proc genArrayAccess(p: PProc, n: PNode, r: var TCompRes) =
var ty = skipTypes(n[0].typ, abstractVarRange)
var ty = skipTypes(n[0].typ, abstractVarRange+tyUserTypeClasses)
if ty.kind in {tyRef, tyPtr, tyLent, tyOwned}: ty = skipTypes(ty.elementType, abstractVarRange)
case ty.kind
of tyArray, tyOpenArray, tySequence, tyString, tyCstring, tyVarargs:

View File

@@ -48,8 +48,16 @@ block:
foo4(x)
block: # bug #9550
type Foo = concept c
for v in c: (v is char)
block:
type Foo = concept c
for v in c: (v is char)
func foo(c: Foo) = (for v in c: discard)
foo @['a', 'b' ,'c']
func foo(c: Foo) = (for v in c: discard)
foo @['a', 'b' ,'c']
block:
type Foo = concept c
for v in c: (v is char)
func foo(c: Foo) = (for v in c: discard)
foo ['a', 'b' ,'c']