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

Internal compiler error for proc alias #8935

Closed
StefanSalewski opened this issue Sep 10, 2018 · 6 comments
Closed

Internal compiler error for proc alias #8935

StefanSalewski opened this issue Sep 10, 2018 · 6 comments

Comments

@StefanSalewski
Copy link

If I remember correctly proc alias with const keyword was possible some years ago. Now with const, let or var we get some different internal errors:

#const
#  myPrint = echo

#let
#  myPuts = system.echo

const # or let or var
  testForMe = assert
testForMe(1 + 1 == 2)

#puts "puts is alias for echo"
#print "print is also alias for echo"
$ nim c t.nim 
Hint: used config file '/home/stefan/Nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: t [Processing]
t.nim(8, 15) Error: internal error: expr(skTemplate); unknown symbol
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp c <file>
stefan@nuc /tmp/hhh $ nim -v
Nim Compiler Version 0.18.1 [Linux: amd64]
Compiled at 2018-09-05
Copyright (c) 2006-2018 by Andreas Rumpf

git hash: 4aba2981dd47672744191bd17b39bb149f494637
active boot switches: -d:release
@andreaferretti
Copy link
Collaborator

It should be possible to do this today as well, but it only makes sense with procs that are non-generic. The generic ones are just "recipes" to instantiate a non-generic one with concrete types, hence it does not make sense to bind it to a runtime variable

@metagn
Copy link
Collaborator

metagn commented Sep 11, 2018

It's still possible, it's just that assert is a template and not a proc, if this was going to work templates would have to be compile time values

@StefanSalewski
Copy link
Author

Ah yes, I forgot that assert() is a template and not a plain proc. But maybe we can improve the error message -- internal error is a bit confusing, although the source of the error is mentioned: expr(skTemplate)

@narimiran
Copy link
Member

But maybe we can improve the error message -- internal error is a bit confusing, although the source of the error is mentioned: expr(skTemplate)

Current devel (0.20.99) produces: Error: VM problem: dest register is not set

timotheecour added a commit to timotheecour/Nim that referenced this issue Jul 25, 2019
@timotheecour
Copy link
Member

timotheecour commented Jul 25, 2019

my PR #11822 fixes this, see test case (works with generics, templates (eg assert), macros (eg echo) etc)

timotheecour added a commit to timotheecour/Nim that referenced this issue Jul 25, 2019
timotheecour added a commit to timotheecour/Nim that referenced this issue Jul 29, 2019
timotheecour added a commit to timotheecour/Nim that referenced this issue Jul 30, 2019
@narimiran
Copy link
Member

But maybe we can improve the error message -- internal error is a bit confusing, although the source of the error is mentioned: expr(skTemplate)

Currently with the latest Nim devel, this is the error message: Error: invalid type: 'template (cond: untyped, msg: string)' for const. Did you mean to call the template with '()'?

I consider this an improved error message.

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