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

Compiler stackoverflow with generics/options #9458

Closed
jwollen opened this issue Oct 21, 2018 · 8 comments
Closed

Compiler stackoverflow with generics/options #9458

jwollen opened this issue Oct 21, 2018 · 8 comments
Assignees

Comments

@jwollen
Copy link
Contributor

jwollen commented Oct 21, 2018

The following causes a stackoverflow in replaceTypeVarsN/S.
Apologies for the unconcreteness. I didn't investigate further :P

import options
type Bar = object
proc foo*[T](self: T; x: Option[Bar] = Bar.none) = discard
foo(1)
@LemonBoy
Copy link
Contributor

I believe this is the same problem reported in another ticket whose number I can't find right now.
Does changing Bar.none into none(Bar) help?

@jwollen
Copy link
Contributor Author

jwollen commented Oct 21, 2018

Nope, same result.

@stefanos82
Copy link

I have tried your code and as soon as I attempt to compile it, it hangs at typetraits processing.

@LemonBoy
Copy link
Contributor

The instantiation of the generic calls the replaceTypeVars* on the default argument value. What happens next is that Bar points to the type Bar = object declaration that in turn points to Bar that points to type Bar = object ... and so on.

@krux02
Copy link
Contributor

krux02 commented Nov 8, 2018

There is a comment about this bug in the source code. It seems to be a tough problem.

# XXX: Bound symbols in default parameter expressions may reach here.

@ghost
Copy link

ghost commented Jun 25, 2020

Works on latest devel, need to add a test-case?

@timotheecour
Copy link
Member

Yes, always :)

@timotheecour
Copy link
Member

closed by #14795

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants