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

Crash in compiler when using system.any by accident. #14255

Closed
treeform opened this issue May 7, 2020 · 2 comments · Fixed by #21562
Closed

Crash in compiler when using system.any by accident. #14255

treeform opened this issue May 7, 2020 · 2 comments · Fixed by #21562

Comments

@treeform
Copy link
Contributor

treeform commented May 7, 2020

Reproduce the error with:

var a = newSeq[bool](1000)
if any(a):
  echo "ok?"

Get compiler crash:

Error: internal error: getTypeDescAux(tyFromExpr)
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp c <file>

I think i am using system.any which is a "meta type" and not sequtils.any. Even though I am using sequtils.any wrong. I expect to get an error some thing like: "system.any can't be created from an seq". Or even some thing less fancy like "invalid type" at line 2.

@ringabout
Copy link
Member

ringabout commented Nov 3, 2020

More cases, auto is same as any:

block:
  var a = newSeq[bool](1000)
  if false:
    echo "ok?"
  elif any(a):
    echo "false"

block:
  var a = newSeq[bool](1000)
  while any(a):
    echo "ok?"

block:
  when any(a):
    echo "when"

It also causes problems in VM:

static:
  ## unhandled exception: 'intVal' is not accessible using discriminant 'kind' of type 'TFullReg' 
  let a = newSeq[bool](1000)
  if any(a):
    echo "ok?"

It works in JS backend.

@ringabout
Copy link
Member

ringabout commented Nov 3, 2020

Could it be fixed before ccg?

It seems hard to fix it in sem phase I guess?

proc hello(a: int): any =
  true

if hello(12):
  echo "ok?"

Araq pushed a commit that referenced this issue Mar 23, 2023
…21562)

fixes #14255; Crash in compiler when using system.any by accident.
capocasa pushed a commit to capocasa/Nim that referenced this issue Mar 31, 2023
…cident. (nim-lang#21562)

fixes nim-lang#14255; Crash in compiler when using system.any by accident.
narimiran pushed a commit that referenced this issue Apr 26, 2023
…21562)

fixes #14255; Crash in compiler when using system.any by accident.

(cherry picked from commit 55636a2)
bung87 pushed a commit to bung87/Nim that referenced this issue Jul 29, 2023
…cident. (nim-lang#21562)

fixes nim-lang#14255; Crash in compiler when using system.any by accident.
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