mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
fix #6277
This commit is contained in:
@@ -849,7 +849,7 @@ proc genArrayElem(p: BProc, n, x, y: PNode, d: var TLoc) =
|
||||
var a, b: TLoc
|
||||
initLocExpr(p, x, a)
|
||||
initLocExpr(p, y, b)
|
||||
var ty = skipTypes(skipTypes(a.t, abstractVarRange), abstractPtrs)
|
||||
var ty = skipTypes(a.t, abstractVarRange + abstractPtrs + tyUserTypeClasses)
|
||||
var first = intLiteral(firstOrd(ty))
|
||||
# emit range check:
|
||||
if optBoundsCheck in p.options and tfUncheckedArray notin ty.flags:
|
||||
|
||||
20
tests/concepts/titerable.nim
Normal file
20
tests/concepts/titerable.nim
Normal file
@@ -0,0 +1,20 @@
|
||||
discard """
|
||||
nimout: "int\nint"
|
||||
output: 15
|
||||
"""
|
||||
|
||||
import typetraits
|
||||
|
||||
type
|
||||
Iterable[T] = concept x
|
||||
for value in x:
|
||||
type(value) is T
|
||||
|
||||
proc sum*[T](iter: Iterable[T]): T =
|
||||
static: echo T.name
|
||||
for element in iter:
|
||||
static: echo element.type.name
|
||||
result += element
|
||||
|
||||
echo sum([1, 2, 3, 4, 5])
|
||||
|
||||
Reference in New Issue
Block a user