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

Can't check if stderr is static #19680

Closed
PMunch opened this issue Apr 5, 2022 · 2 comments · Fixed by #19709
Closed

Can't check if stderr is static #19680

PMunch opened this issue Apr 5, 2022 · 2 comments · Fixed by #19709

Comments

@PMunch
Copy link
Contributor

PMunch commented Apr 5, 2022

While working on Futhark I wanted to decide whether or not to put something into a const or a let. Basically it tries to read out macros which can resolve to simple numbers and I want those to be consts, but it can also be other stuff which can't go into a const. I came if with a solution of using when x is static: const y = x else: let y = x which works fine for most identifiers. But certain built-ins like stdout and stderr makes the compiler crash.

Example

when stderr is static:
  echo "whoops"
else:
  echo "works"

Current Output

fatal.nim(53)            sysFatal
Error: unhandled exception: index -1 not in 0 .. 0 [IndexDefect]

Expected Output

works

Possible Solution

Not really sure what a possible solution would be, but building a debug compiler gives a lot more output to work with.

@Cloudperry
Copy link

Your code might be triggering the same underlying compiler bug that I hit with nim-regex. The last 6 lines of the debug compiler stack trace are the same as with the code here: nitely/nim-regex#107. Idk if this is helpful at all, because it seems your code is a simpler way to trigger the same bug.

@ringabout
Copy link
Member

ringabout commented Apr 10, 2022

built-ins like stdout and stderr are importc symbols

see #19709

It is a regression since 1.2.0 caused by #12877

narimiran pushed a commit that referenced this issue Apr 24, 2022
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.

3 participants