Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unittest "generic instantiation too nested" error #11515

Closed
nitely opened this issue Jun 17, 2019 · 1 comment

Comments

@nitely
Copy link
Contributor

commented Jun 17, 2019

unittest check function throws the following error. Using doAssert instead works fine. Saddly, I have no idea how to reproduce this without regex module. It used to work in Nim 0.18, 0.19.0 and 0.19.6.

Edit: it's related to the use of contains

Example

import regex

test "tflags":
  # line 771
  check(re"""(?x)    # verbose mode
    ^                   # beginning of string
    M{0,4}              # thousands - 0 to 4 M's
    (CM|CD|D?C{0,3})    # hundreds - 900 (CM), 400 (CD), 0-300 (0 to 3 C's),
                        #            or 500-800 (D, followed by 0 to 3 C's)
    (XC|XL|L?X{0,3})    # tens - 90 (XC), 40 (XL), 0-30 (0 to 3 X's),
                        #        or 50-80 (L, followed by 0 to 3 X's)
    (IX|IV|V?I{0,3})    # ones - 9 (IX), 4 (IV), 0-3 (0 to 3 I's),
                        #        or 5-8 (V, followed by 0 to 3 I's)
    $                   # end of string
    """ in "MMMMDCCCLXXXVIII")

Current Output

/home/esteban/AtomProjects/nim-regex/tests/tests.nim(630, 6) template/generic instantiation of `test` from here
/home/esteban/AtomProjects/nim-regex/tests/tests.nim(771, 8) template/generic instantiation of `check` from here
/home/esteban/.choosenim/toolchains/nim-#devel/lib/pure/unittest.nim(600, 35) template/generic instantiation of `$` from here
/home/esteban/.choosenim/toolchains/nim-#devel/lib/system/dollars.nim(90, 15) template/generic instantiation of `addQuoted` from here
/home/esteban/.choosenim/toolchains/nim-#devel/lib/system/dollars.nim(134, 21) template/generic instantiation of `collectionToString` from here
/home/esteban/.choosenim/toolchains/nim-#devel/lib/system/dollars.nim(117, 13) template/generic instantiation of `addQuoted` from here
/home/esteban/.choosenim/toolchains/nim-#devel/lib/system.nim(4223, 11) Error: generic instantiation too nested
stack trace: (most recent call last)

Additional Information

Nim Compiler Version 0.20.99 [Linux: amd64]
Compiled at 2019-06-17
Copyright (c) 2006-2019 by Andreas Rumpf

active boot switches: -d:release

^ can reproduce it in Nim 0.20.0 as well.

@mratsim

This comment has been minimized.

Copy link
Collaborator

commented Jun 21, 2019

I had this issue in the past in one of Status libraries that uses templates and generics a lot (the generic type is recursive).

To solve this I somehow had to export some functions publicly:

@Araq Araq added the Regression label Jun 29, 2019

Araq added a commit that referenced this issue Jun 29, 2019

Araq added a commit that referenced this issue Jul 1, 2019

@Araq Araq closed this in 766960d Jul 1, 2019

narimiran added a commit that referenced this issue Jul 2, 2019

fixes #11515 (#11624)
* fixes #11515

* better fix for #11515; make tests green

(cherry picked from commit 766960d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.