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

generic types parameter asserts the compiler (#2) #22647

Closed
dagan-deon opened this issue Sep 5, 2023 · 8 comments · Fixed by #24005
Closed

generic types parameter asserts the compiler (#2) #22647

dagan-deon opened this issue Sep 5, 2023 · 8 comments · Fixed by #24005
Labels

Comments

@dagan-deon
Copy link

Description

proc c0(n: static int): int = 8
proc c1(n: static int): int = n div 2
proc c2(n: static int): int = n * 2

type
  a[N: static int] = object
    f0 : array[N, int]

  b[N: static int] = object
    f0 : a[c0(N)]  # does not work
    f1 : a[c1(N)]  # does not work
    f2 : a[c2(N)]  # does not work
    f3 : a[N * 2]  # does not work
    f4 : a[N]      # works

proc p[N: static int](x : a[N]) = echo x.f0[0]
proc p[N: static int](x : b[N]) =
  x.f0.p()
  x.f1.p()
  x.f2.p()
  x.f3.p()
  x.f4.p()

var x: b[4]
x.p()

Nim Version

Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2023-09-05
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 8f7aedb
active boot switches: -d:release

Current Output

......................................................................assertions.nim(34)       raiseAssert
Error: unhandled exception: int128.nim(66, 11) `arg.sdata(3) == -1` out of range [AssertionDefect]

shell returned 1

Expected Output

No response

Possible Solution

No response

Additional Information

No response

@dagan-deon
Copy link
Author

!nim c

proc c0(n: static int): int = 8
proc c1(n: static int): int = n div 2
proc c2(n: static int): int = n * 2

type
  a[N: static int] = object
    f0 : array[N, int]

  b[N: static int] = object
    f0 : a[c0(N)]  # does not work
    f1 : a[c1(N)]  # does not work
    f2 : a[c2(N)]  # does not work
    f3 : a[N * 2]  # does not work
    f4 : a[N]      # works

proc p[N: static int](x : a[N]) = echo x.f0[0]
proc p[N: static int](x : b[N]) =
  x.f0.p()
  x.f1.p()
  x.f2.p()
  x.f3.p()
  x.f4.p()

var x: b[4]
x.p()

@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2023

@dagan-deon (none)

devel 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
assertions.nim(34)       raiseAssert
Error: unhandled exception: int128.nim(66, 11) `arg.sdata(3) == -1` out of range [AssertionDefect]

Stats

  • Started 2023-09-05T11:21:31
  • Finished 2023-09-05T11:21:31
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("c0"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(8)
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c1"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("div"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("*"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("a"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              newIdentNode("N"),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("b"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c0"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f1"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c1"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f2"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c2"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f3"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkInfix.newTree(
                newIdentNode("*"),
                newIdentNode("N"),
                newLit(2)
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f4"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              newIdentNode("N")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("a"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkBracketExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newLit(0)
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("b"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f1")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f2")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f3")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f4")
          ),
          newIdentNode("p")
        )
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("x"),
      nnkBracketExpr.newTree(
        newIdentNode("b"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkCall.newTree(
    nnkDotExpr.newTree(
      newIdentNode("x"),
      newIdentNode("p")
    )
  )
)
stable 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
assertions.nim(34)       raiseAssert
Error: unhandled exception: semtypinst.nim(259, 7) `result.kind notin nkCallKinds`  [AssertionDefect]

Stats

  • Started 2023-09-05T11:21:32
  • Finished 2023-09-05T11:21:32
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("c0"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(8)
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c1"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("div"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("*"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("a"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              newIdentNode("N"),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("b"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c0"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f1"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c1"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f2"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c2"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f3"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkInfix.newTree(
                newIdentNode("*"),
                newIdentNode("N"),
                newLit(2)
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f4"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              newIdentNode("N")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("a"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkBracketExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newLit(0)
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("b"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f1")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f2")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f3")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f4")
          ),
          newIdentNode("p")
        )
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("x"),
      nnkBracketExpr.newTree(
        newIdentNode("b"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkCall.newTree(
    nnkDotExpr.newTree(
      newIdentNode("x"),
      newIdentNode("p")
    )
  )
)
2.0.0 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
assertions.nim(34)       raiseAssert
Error: unhandled exception: semtypinst.nim(259, 7) `result.kind notin nkCallKinds`  [AssertionDefect]

Stats

  • Started 2023-09-05T11:21:33
  • Finished 2023-09-05T11:21:33
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("c0"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(8)
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c1"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("div"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("*"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("a"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              newIdentNode("N"),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("b"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c0"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f1"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c1"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f2"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c2"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f3"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkInfix.newTree(
                newIdentNode("*"),
                newIdentNode("N"),
                newLit(2)
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f4"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              newIdentNode("N")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("a"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkBracketExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newLit(0)
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("b"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f1")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f2")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f3")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f4")
          ),
          newIdentNode("p")
        )
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("x"),
      nnkBracketExpr.newTree(
        newIdentNode("b"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkCall.newTree(
    nnkDotExpr.newTree(
      newIdentNode("x"),
      newIdentNode("p")
    )
  )
)
1.6.0 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(2, 33) Error: cannot generate VM code for div

Stats

  • Started 2023-09-05T11:21:36
  • Finished 2023-09-05T11:21:36
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("c0"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(8)
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c1"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("div"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("*"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("a"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              newIdentNode("N"),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("b"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c0"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f1"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c1"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f2"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c2"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f3"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkInfix.newTree(
                newIdentNode("*"),
                newIdentNode("N"),
                newLit(2)
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f4"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              newIdentNode("N")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("a"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkBracketExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newLit(0)
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("b"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f1")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f2")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f3")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f4")
          ),
          newIdentNode("p")
        )
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("x"),
      nnkBracketExpr.newTree(
        newIdentNode("b"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkCall.newTree(
    nnkDotExpr.newTree(
      newIdentNode("x"),
      newIdentNode("p")
    )
  )
)
1.4.0 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(2, 33) Error: cannot generate VM code for div

Stats

  • Started 2023-09-05T11:21:39
  • Finished 2023-09-05T11:21:39
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("c0"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(8)
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c1"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("div"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("*"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("a"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              newIdentNode("N"),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("b"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c0"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f1"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c1"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f2"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c2"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f3"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkInfix.newTree(
                newIdentNode("*"),
                newIdentNode("N"),
                newLit(2)
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f4"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              newIdentNode("N")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("a"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkBracketExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newLit(0)
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("b"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f1")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f2")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f3")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f4")
          ),
          newIdentNode("p")
        )
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("x"),
      nnkBracketExpr.newTree(
        newIdentNode("b"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkCall.newTree(
    nnkDotExpr.newTree(
      newIdentNode("x"),
      newIdentNode("p")
    )
  )
)
1.2.0 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(2, 33) Error: cannot generate VM code for div

Stats

  • Started 2023-09-05T11:21:54
  • Finished 2023-09-05T11:21:54
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("c0"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(8)
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c1"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("div"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("*"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("a"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              newIdentNode("N"),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("b"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c0"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f1"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c1"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f2"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c2"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f3"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkInfix.newTree(
                newIdentNode("*"),
                newIdentNode("N"),
                newLit(2)
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f4"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              newIdentNode("N")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("a"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkBracketExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newLit(0)
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("b"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f1")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f2")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f3")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f4")
          ),
          newIdentNode("p")
        )
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("x"),
      nnkBracketExpr.newTree(
        newIdentNode("b"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkCall.newTree(
    nnkDotExpr.newTree(
      newIdentNode("x"),
      newIdentNode("p")
    )
  )
)
1.0.0 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(2, 33) Error: cannot generate VM code for div

Stats

  • Started 2023-09-05T11:22:05
  • Finished 2023-09-05T11:22:05
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("c0"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(8)
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c1"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("div"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("*"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("a"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              newIdentNode("N"),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("b"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c0"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f1"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c1"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f2"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c2"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f3"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkInfix.newTree(
                newIdentNode("*"),
                newIdentNode("N"),
                newLit(2)
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f4"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              newIdentNode("N")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("a"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkBracketExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newLit(0)
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("b"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f1")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f2")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f3")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f4")
          ),
          newIdentNode("p")
        )
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("x"),
      nnkBracketExpr.newTree(
        newIdentNode("b"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkCall.newTree(
    nnkDotExpr.newTree(
      newIdentNode("x"),
      newIdentNode("p")
    )
  )
)
0.20.2 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(2, 33) Error: cannot generate VM code for div

Stats

  • Started 2023-09-05T11:22:14
  • Finished 2023-09-05T11:22:15
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("c0"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(8)
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c1"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("div"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("c2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("n"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkInfix.newTree(
        newIdentNode("*"),
        newIdentNode("n"),
        newLit(2)
      )
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("a"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              newIdentNode("N"),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("b"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("N"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("f0"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c0"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f1"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c1"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f2"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkCall.newTree(
                newIdentNode("c2"),
                newIdentNode("N")
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f3"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              nnkInfix.newTree(
                newIdentNode("*"),
                newIdentNode("N"),
                newLit(2)
              )
            ),
            newEmptyNode()
          ),
          nnkIdentDefs.newTree(
            newIdentNode("f4"),
            nnkBracketExpr.newTree(
              newIdentNode("a"),
              newIdentNode("N")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("a"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkBracketExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newLit(0)
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("p"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("N"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("b"),
          newIdentNode("N")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f0")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f1")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f2")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f3")
          ),
          newIdentNode("p")
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("x"),
            newIdentNode("f4")
          ),
          newIdentNode("p")
        )
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("x"),
      nnkBracketExpr.newTree(
        newIdentNode("b"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkCall.newTree(
    nnkDotExpr.newTree(
      newIdentNode("x"),
      newIdentNode("p")
    )
  )
)
Stats
  • GCC 11.4.0
  • LibC 2.35
  • Valgrind 3.18.1
  • NodeJS 17.1
  • Linux 5.15.0
  • Created 2023-09-05T11:18:30Z
  • Comments 1
  • Commands nim c --run -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

🤖 Bug found in 46 minutes bisecting 8 commits at 0 commits per second.

@metagn
Copy link
Collaborator

metagn commented Sep 11, 2023

Not an early generic semchecking bug, for some reason N stays unresolved inside the type during the proc instantiations. The var x: b[4] by itself instantiates completely fine for example if you do echo x

@dagan-deon
Copy link
Author

What is the status/plan for this?

  1. fixable: long-term or short-term?
  2. not fixable, but there is a workaround.
  3. not fixable, won't be supported by the language in the foreseeable future.

@metagn
Copy link
Collaborator

metagn commented Sep 29, 2023

I mean it should work. Can't really say when it will be fixed if someone doesn't have a solution, and no one has suggested one.

Can't think of a workaround right now either.

@dagan-deon
Copy link
Author

ok thanks. I think I will need to make time to dig into the compiler internals.

@metagn
Copy link
Collaborator

metagn commented Jul 20, 2024

Seems to work now? No idea how

@metagn
Copy link
Collaborator

metagn commented Jul 20, 2024

It compiles but the p(a[N]) overload seems to infer N as 1 for every field except f4. If you change it to echo x.f0.len instead of echo x.f0[0], the output is:

1
1
1
1
4

And changing it to echo x.f0 just crashes the compiler. It seems the type of the array literally becomes something like array[typeof(c0(N)), int].

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