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

Bind does not work with dot call syntax #15246

Closed
bluenote10 opened this issue Aug 30, 2020 · 3 comments · Fixed by #22564
Closed

Bind does not work with dot call syntax #15246

bluenote10 opened this issue Aug 30, 2020 · 3 comments · Fixed by #22564

Comments

@bluenote10
Copy link
Contributor

bluenote10 commented Aug 30, 2020

I haven't written much Nim recently, so I hope I'm not doing anything stupid.

Example

lib.nim
import os

template sourceBaseName*(): string =
  bind splitFile
  instantiationInfo().filename.splitFile().name
user.nim
import lib

echo sourceBaseName()

Current Output

$ nim c user.nim
Hint: used config file '/home/fabian/bin/nim-repo/config/nim.cfg' [Conf]
Hint: used config file '/home/fabian/bin/nim-repo/config/config.nims' [Conf]
...................
/tmp/nimtest/user.nim(3, 20) template/generic instantiation of `sourceBaseName` from here
/tmp/nimtest/lib.nim(5, 31) Error: attempting to call undeclared routine: 'splitFile'

Expected Output

Expected to compile because lib.nim explicitly does bind splitFile.

The code works if the user manually imports os, but my understanding was that the purpose of bind is to avoid that.

Additional Information

I can't say for sure, but it could be a regression, because:

$ nim -v
Nim Compiler Version 1.3.5 [Linux: amd64]
Compiled at 2020-08-30
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: b5424b826e57c791a751bf31b69549c7d8daab0b
active boot switches: -d:release
@Araq
Copy link
Member

Araq commented Aug 31, 2020

Not sure either but please try it to call splitFile without the dot call syntax.

@bluenote10 bluenote10 changed the title Bind does not work? Bind does not work with dot call syntax Sep 5, 2020
@bluenote10
Copy link
Contributor Author

please try it to call splitFile without the dot call syntax.

Yes that seems to work, so the problem is specific to dot call syntax.

@metagn
Copy link
Collaborator

metagn commented Aug 27, 2023

Compiles as of 2.0

metagn added a commit to metagn/Nim that referenced this issue Aug 27, 2023
closes nim-lang#12582, closes nim-lang#19552, closes nim-lang#2465, closes nim-lang#4596, closes nim-lang#15246,
closes nim-lang#12683, closes nim-lang#7889, closes nim-lang#4547, closes nim-lang#12415, closes nim-lang#2002,
closes nim-lang#1771, closes nim-lang#5121

The test for nim-lang#5648 is also moved into its own test
from `types/tissues_types` due to not being joinable.
@Araq Araq closed this as completed Aug 27, 2023
Araq pushed a commit that referenced this issue Aug 27, 2023
* test case haul for old generic/template/macro issues

closes #12582, closes #19552, closes #2465, closes #4596, closes #15246,
closes #12683, closes #7889, closes #4547, closes #12415, closes #2002,
closes #1771, closes #5121

The test for #5648 is also moved into its own test
from `types/tissues_types` due to not being joinable.

* fix template gensym test
narimiran pushed a commit that referenced this issue Sep 18, 2023
* test case haul for old generic/template/macro issues

closes #12582, closes #19552, closes #2465, closes #4596, closes #15246,
closes #12683, closes #7889, closes #4547, closes #12415, closes #2002,
closes #1771, closes #5121

The test for #5648 is also moved into its own test
from `types/tissues_types` due to not being joinable.

* fix template gensym test

(cherry picked from commit c19fd69)
narimiran pushed a commit that referenced this issue Sep 18, 2023
* test case haul for old generic/template/macro issues

closes #12582, closes #19552, closes #2465, closes #4596, closes #15246,
closes #12683, closes #7889, closes #4547, closes #12415, closes #2002,
closes #1771, closes #5121

The test for #5648 is also moved into its own test
from `types/tissues_types` due to not being joinable.

* fix template gensym test

(cherry picked from commit c19fd69)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants