You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#from combinatorics import combinationsiteratorcombinations[T](a: openArray[T]; n: int): seq[T] =# stupid fake iteratorvar i =0while i <len(a):
var h: seq[T]
h.setLen(0)
for x in0.. n:
h.add(a[i])
yield h
inc(i)
procmain=var unp: seq[int]
block myb:
unp =@[1, 2, 3]
for t in unp.combinations(2):
try:
for k in t:
echo k
assert k !=1break myb
except:
echo"exception"main()
$ nim c -r arcbug.nim
/arcbug.nim; out: /home/stefan/gintrotest/tests/arcbug [SuccessX]
Hint: /home/stefan/gintrotest/tests/arcbug [Exec]
1
exception
2
2
2
stefan@nuc ~/gintrotest/tests $ nim c --gc:arc -r arcbug.nim
/arcbug.nim; out: /home/stefan/gintrotest/tests/arcbug [SuccessX]
Hint: /home/stefan/gintrotest/tests/arcbug [Exec]
1
Traceback (most recent call last)
/home/stefan/gintrotest/tests/arcbug.nim(26) arcbug
/home/stefan/gintrotest/tests/arcbug.nim(21) main
/home/stefan/Nim/lib/system/assertions.nim(27) failedAssertImpl
/home/stefan/Nim/lib/system/assertions.nim(20) raiseAssert
/home/stefan/Nim/lib/system/fatal.nim(45) sysFatal
/home/stefan/Nim/lib/system/fatal.nim(33) sysFatal
Error: unhandled exception: /home/stefan/gintrotest/tests/arcbug.nim(21, 18) `k != 1` [AssertionError]
Error: execution of an external program failed: '/home/stefan/gintrotest/tests/arcbug '
stefan@nuc ~/gintrotest/tests $ nim -v
Nim Compiler Version 1.1.1 [Linux: amd64]
Compiled at 2020-02-21
Copyright (c) 2006-2019 by Andreas Rumpf
git hash: 3667fd9f426eac968c326b3dc9571b7b7e8fef67
active boot switches: -d:release
The text was updated successfully, but these errors were encountered:
This is the documented behaviour of --goto:exceptions and hence not a bug. I know it's disliked by many but that doesn't make it a bug.
IMO this will cause real problems when migrating to --gc:arc, and prevents code testability based on doAssertRaises + other things I mentioned in that issue, so we should simply have a compiler flag --catchdefects:on/off to control whether or not Defects (like AssectionError, IndexError etc) are allowed to be caught with --goto:exceptions (implied by --gc:arc)
The text was updated successfully, but these errors were encountered: