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

Compiler crash with sequence of proc #19562

Open
iacore opened this issue Feb 23, 2022 · 0 comments
Open

Compiler crash with sequence of proc #19562

iacore opened this issue Feb 23, 2022 · 0 comments
Labels
Closures Compiler Crash VM see also `const` label

Comments

@iacore
Copy link
Contributor

iacore commented Feb 23, 2022

When I was trying to make mapIt shorter in #19557, I discovered this bug.

Example

template mapIt*(s: typed, op: untyped): untyped =
  type OutType = typeof(
    block:
      var it{.inject.}: typeof(items(s));
      op
  )

  block:
    var result: seq[OutType]
    for it {.inject.} in s:
      result &= op
    result

static:
  let m = @[func (x: int): int = x + 100, func (x: int): int = x + 200]
  echo m.mapIt(func (x: int): int = it(x)).mapIt(it 1)

Current Output

> nim r test2.nim
Hint: used config file '/home/user/.choosenim/toolchains/nim-1.6.4/config/nim.cfg' [Conf]
Hint: used config file '/home/user/.choosenim/toolchains/nim-1.6.4/config/config.nims' [Conf]
.........................................................fatal.nim(53)            sysFatal
Error: unhandled exception: index 9 not in 0 .. 3 [IndexDefect]

Expected Output

The compiler should not crash.

Additional Information

TODO: bisect
at least present since 1.7.1

> nim -v
Nim Compiler Version 1.6.4 [Linux: amd64]
Compiled at 2022-02-09
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 7994556f3804c217035c44b453a3feec64405758
active boot switches: -d:release

@ringabout ringabout added the VM see also `const` label label Jun 20, 2022
@bung87 bung87 changed the title Compiler crash Compiler crash with sequence of proc Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closures Compiler Crash VM see also `const` label
Projects
None yet
Development

No branches or pull requests

3 participants