Skip to content

Nim check hangs in macro #9829

Closed
Closed
@liwt31

Description

@liwt31

Nim check hangs in macro. Don't know what exactly caused this.

Example

Content of bug.nim:

macro foo(): untyped  = 
  let lines = ["123", "5423"]
  var idx = 0
  while idx < lines.len():
    if lines[idx].len() < 1: 
      inc(idx)
      continue
 
foo()

Current Output

$ nim check bug.nim 
Hint: used config file '/home/wtli/.choosenim/toolchains/nim-0.19.0/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: bug [Processing]
^CSIGINT: Interrupted by Ctrl-C.
Traceback (most recent call last)
proxyexe.nim(62)         proxyexe
proxyexe.nim(49)         main
osproc.nim(1136)         waitForExit
SIGINT: Interrupted by Ctrl-C.

The program hangs in Hint: bug [Processing] until a SIGINT.

Expected Output

I know there's a infinite loop, but I've seen:

Error: interpretation requires too many iterations; if you are sure this is not a bug in your code edit compiler/vmdef.MaxLoopIterations and rebuild the compiler

before in a simpler case. That's a lot nicer (and very cool!).

Possible Solution

Donno.

Additional Information

Nim Compiler Version 0.19.0 [Linux: amd64]
Compiled at 2018-09-26
Copyright (c) 2006-2018 by Andreas Rumpf

git hash: f6c5c636bb1a1f4e1301ae0ba5a8afecef439132
active boot switches: -d:release
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Thank you in advance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions