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

importing a generic function which imports a generic type fails to compile but including it works #19268

Closed
ni-max opened this issue Dec 17, 2021 · 1 comment

Comments

@ni-max
Copy link

ni-max commented Dec 17, 2021

@Araq to reproduce the bug discussed here: #19233
I've created a sample project as a gist: https://gist.github.com/4945609c860f52cb97fbbc4081510772

As you can see notcompiles.nim does not compile (tested with #head #devel 1.7.1 and 1.6.0 compilers) ❌
But compiles.nim which uses include instead of import compiles without error. ✅
Also compiles2.nim which uses import without generics compiles without error. ✅

Is this a bug or am I missing something?

$ nim c -r --hints:off notcompiles.nim
./notcompiles.nim(3, 7) template/generic instantiation of `f` from here
./module.nim(4, 14) template/generic instantiation of `toDeque` from here
./bug.nim(8, 11) Error: attempting to call undeclared routine: 'addLast'
$ nim c -r --hints:off compiles.nim
1

$ nim c -r --hints:off compiles2.nim
1
$ nim -v
Nim Compiler Version 1.7.1 [MacOSX: amd64]
Compiled at 2021-12-16
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 5d2bab7558b54813b212a26fbcdb51556ff37b05
@metagn
Copy link
Collaborator

metagn commented Nov 9, 2024

addLast is mixed in in toDeque since it isn't defined yet, and notcompiles does not import addLast so it's not resolved. Should work with --experimental:typeBoundOps (#24315) but expected regardless.

@metagn metagn closed this as completed Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants