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

Unable to alias echo from the system module #11731

Closed
bifunctor opened this issue Jul 14, 2019 · 3 comments
Closed

Unable to alias echo from the system module #11731

bifunctor opened this issue Jul 14, 2019 · 3 comments
Labels

Comments

@bifunctor
Copy link

When I try to import echo from the system module under the alias my_echo, I get this error:

c:\Users\Obround\Desktop\Nim_tests\my_test.nim(1, 25) Error: identifier expected, but found 'echo as my_echo'

This is my code:

from system import echo as my_echo
my_echo "Hello World"

I believe this error is happening because the compiler thinks I want to echo an output instead of alias it. Is this a bug, or am I doing something incorrect (I think its a bug)?

@mratsim mratsim added the Parser label Jul 15, 2019
@mratsim
Copy link
Collaborator

mratsim commented Jul 15, 2019

It seems like echo is treated as a keyword when parsing and only the following structure is allowed from [module identifier] import [identifier] as [identifier].

echo is not listed as a keyword in the manual though: https://nim-lang.org/docs/manual.html#lexical-analysis-identifiers-amp-keywords

@Araq
Copy link
Member

Araq commented Jul 15, 2019

That's not how as works, you can only use as to alias module names, not arbitrary identifiers. And for modules this feature only exists to allow for multiple modules of the same name to be imported.

@timotheecour
Copy link
Member

my PR #11822 fixes this: my_echo:=system.echo works

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