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

Nim 2.0/devel inconsistency between equivalant code building or not #22491

Closed
tersec opened this issue Aug 17, 2023 · 4 comments · Fixed by #22499
Closed

Nim 2.0/devel inconsistency between equivalant code building or not #22491

tersec opened this issue Aug 17, 2023 · 4 comments · Fixed by #22499

Comments

@tersec
Copy link
Contributor

tersec commented Aug 17, 2023

Description

proc log2trunc(x: uint64 | uint64): int =
  if x == 0: int(0) else: int(0)
template maxChunkIdx(T: type): int64 = 0'i64
template layer(vIdx: int64): int = log2trunc(0'u64)
template int2(x: int): int = x
type HashList[T] = object
  indices: array[int(layer(maxChunkIdx(T))), int]

does not compile (see current output section) but

proc log2trunc(x: uint64 | uint64): int =
  if x == 0: int(0) else: int(0)
template maxChunkIdx(T: type): int64 = 0'i64
template layer(vIdx: int64): int = log2trunc(0'u64)
template int2(x: int): int = x
type HashList[T] = object
  indices: array[int2(layer(maxChunkIdx(T))), int]

does compile, on Nim 2.0 and Nim devel, as does

proc log2trunc(x: uint64 | uint64): int =
  if x == 0: int(0) else: int(0)
template maxChunkIdx(T: type): int64 = 0'i64
template layer(vIdx: int64): int = log2trunc(0'u64)
template int2(x: int): int = x
type HashList[T] = object
  indices: array[layer(maxChunkIdx(T)), int]

There's both

  • a strange error message (maxChunkIdx returns int64 and layer takes an int64) and
  • an inconsistency between whether apparently equivalent (layer() is a function from int64 to int, so int(layer(...)) should be equivalent to layer(...)) code builds or not.

Nim 1.6 has a different problem with this, evidently addressed in 2.0 already:

a.nim(2, 8) Error: cannot generate VM code for ==

Nim Version

Nim Compiler Version 2.0.1 [Linux: amd64]
Compiled at 2023-08-16
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 037f536e7ee25c4baf23dff8a4525825c506442c
active boot switches: -d:release
Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2023-08-16
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: ade75a148332e670244a719202f7f0337d2e469a
active boot switches: -d:release

Current Output

a.nim(7, 27) Error: type mismatch
Expression: layer(maxChunkIdx(T))
  [1] maxChunkIdx(T): typeof(maxChunkIdx(T))

Expected one of (first mismatch at [position]):
[1] template layer(vIdx: int64): int

Expected Output

Consistently build or consistently don't build

Possible Solution

No response

Additional Information

No response

@ringabout
Copy link
Member

!nim c

proc log2trunc(x: uint64 | uint64): int =
  if x == 0: int(0) else: int(0)
template maxChunkIdx(T: type): int64 = 0'i64
template layer(vIdx: int64): int = log2trunc(0'u64)
template int2(x: int): int = x
type HashList[T] = object
  indices: array[int(layer(maxChunkIdx(T))), int]

@github-actions
Copy link
Contributor

@ringabout (member)

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
/home/runner/work/Nim/Nim/temp.nim(7, 27) Error: type mismatch
Expression: layer(maxChunkIdx(T))
  [1] maxChunkIdx(T): typeof(maxChunkIdx(T))

Expected one of (first mismatch at [position]):
[1] template layer(vIdx: int64): int

Stats

  • Started 2023-08-17T01:25:27
  • Finished 2023-08-17T01:25:27
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("log2trunc"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkInfix.newTree(
          newIdentNode("|"),
          newIdentNode("uint64"),
          newIdentNode("uint64")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("=="),
            newIdentNode("x"),
            newLit(0)
          ),
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        ),
        nnkElse.newTree(
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("maxChunkIdx"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int64"),
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newIdentNode("type"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(0)
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("layer"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("vIdx"),
        newIdentNode("int64"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("log2trunc"),
        nnkUInt64Lit.newTree(
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("int2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("int"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("x")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("HashList"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("indices"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              nnkCall.newTree(
                newIdentNode("int"),
                nnkCall.newTree(
                  newIdentNode("layer"),
                  nnkCall.newTree(
                    newIdentNode("maxChunkIdx"),
                    newIdentNode("T")
                  )
                )
              ),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    )
  )
)
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
/home/runner/work/Nim/Nim/temp.nim(7, 27) Error: type mismatch
Expression: layer(maxChunkIdx(T))
  [1] maxChunkIdx(T): typeof(maxChunkIdx(T))

Expected one of (first mismatch at [position]):
[1] template layer(vIdx: int64): int

Stats

  • Started 2023-08-17T01:25:28
  • Finished 2023-08-17T01:25:28
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("log2trunc"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkInfix.newTree(
          newIdentNode("|"),
          newIdentNode("uint64"),
          newIdentNode("uint64")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("=="),
            newIdentNode("x"),
            newLit(0)
          ),
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        ),
        nnkElse.newTree(
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("maxChunkIdx"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int64"),
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newIdentNode("type"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(0)
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("layer"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("vIdx"),
        newIdentNode("int64"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("log2trunc"),
        nnkUInt64Lit.newTree(
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("int2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("int"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("x")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("HashList"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("indices"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              nnkCall.newTree(
                newIdentNode("int"),
                nnkCall.newTree(
                  newIdentNode("layer"),
                  nnkCall.newTree(
                    newIdentNode("maxChunkIdx"),
                    newIdentNode("T")
                  )
                )
              ),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    )
  )
)
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
/home/runner/work/Nim/Nim/temp.nim(7, 27) Error: type mismatch
Expression: layer(maxChunkIdx(T))
  [1] maxChunkIdx(T): typeof(maxChunkIdx(T))

Expected one of (first mismatch at [position]):
[1] template layer(vIdx: int64): int

Stats

  • Started 2023-08-17T01:25:29
  • Finished 2023-08-17T01:25:29
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("log2trunc"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkInfix.newTree(
          newIdentNode("|"),
          newIdentNode("uint64"),
          newIdentNode("uint64")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("=="),
            newIdentNode("x"),
            newLit(0)
          ),
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        ),
        nnkElse.newTree(
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("maxChunkIdx"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int64"),
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newIdentNode("type"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(0)
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("layer"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("vIdx"),
        newIdentNode("int64"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("log2trunc"),
        nnkUInt64Lit.newTree(
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("int2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("int"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("x")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("HashList"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("indices"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              nnkCall.newTree(
                newIdentNode("int"),
                nnkCall.newTree(
                  newIdentNode("layer"),
                  nnkCall.newTree(
                    newIdentNode("maxChunkIdx"),
                    newIdentNode("T")
                  )
                )
              ),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    )
  )
)
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, 8) Error: cannot generate VM code for ==

Stats

  • Started 2023-08-17T01:25:32
  • Finished 2023-08-17T01:25:32
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("log2trunc"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkInfix.newTree(
          newIdentNode("|"),
          newIdentNode("uint64"),
          newIdentNode("uint64")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("=="),
            newIdentNode("x"),
            newLit(0)
          ),
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        ),
        nnkElse.newTree(
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("maxChunkIdx"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int64"),
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newIdentNode("type"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(0)
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("layer"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("vIdx"),
        newIdentNode("int64"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("log2trunc"),
        nnkUInt64Lit.newTree(
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("int2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("int"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("x")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("HashList"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("indices"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              nnkCall.newTree(
                newIdentNode("int"),
                nnkCall.newTree(
                  newIdentNode("layer"),
                  nnkCall.newTree(
                    newIdentNode("maxChunkIdx"),
                    newIdentNode("T")
                  )
                )
              ),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    )
  )
)
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, 8) Error: cannot generate VM code for ==

Stats

  • Started 2023-08-17T01:25:35
  • Finished 2023-08-17T01:25:35
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("log2trunc"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkInfix.newTree(
          newIdentNode("|"),
          newIdentNode("uint64"),
          newIdentNode("uint64")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("=="),
            newIdentNode("x"),
            newLit(0)
          ),
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        ),
        nnkElse.newTree(
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("maxChunkIdx"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int64"),
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newIdentNode("type"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(0)
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("layer"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("vIdx"),
        newIdentNode("int64"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("log2trunc"),
        nnkUInt64Lit.newTree(
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("int2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("int"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("x")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("HashList"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("indices"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              nnkCall.newTree(
                newIdentNode("int"),
                nnkCall.newTree(
                  newIdentNode("layer"),
                  nnkCall.newTree(
                    newIdentNode("maxChunkIdx"),
                    newIdentNode("T")
                  )
                )
              ),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    )
  )
)
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, 8) Error: cannot generate VM code for ==

Stats

  • Started 2023-08-17T01:25:51
  • Finished 2023-08-17T01:25:52
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("log2trunc"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkInfix.newTree(
          newIdentNode("|"),
          newIdentNode("uint64"),
          newIdentNode("uint64")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("=="),
            newIdentNode("x"),
            newLit(0)
          ),
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        ),
        nnkElse.newTree(
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("maxChunkIdx"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int64"),
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newIdentNode("type"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(0)
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("layer"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("vIdx"),
        newIdentNode("int64"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("log2trunc"),
        nnkUInt64Lit.newTree(
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("int2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("int"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("x")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("HashList"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("indices"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              nnkCall.newTree(
                newIdentNode("int"),
                nnkCall.newTree(
                  newIdentNode("layer"),
                  nnkCall.newTree(
                    newIdentNode("maxChunkIdx"),
                    newIdentNode("T")
                  )
                )
              ),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    )
  )
)
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, 8) Error: cannot generate VM code for ==

Stats

  • Started 2023-08-17T01:26:02
  • Finished 2023-08-17T01:26:02
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("log2trunc"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkInfix.newTree(
          newIdentNode("|"),
          newIdentNode("uint64"),
          newIdentNode("uint64")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("=="),
            newIdentNode("x"),
            newLit(0)
          ),
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        ),
        nnkElse.newTree(
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("maxChunkIdx"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int64"),
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newIdentNode("type"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(0)
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("layer"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("vIdx"),
        newIdentNode("int64"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("log2trunc"),
        nnkUInt64Lit.newTree(
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("int2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("int"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("x")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("HashList"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("indices"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              nnkCall.newTree(
                newIdentNode("int"),
                nnkCall.newTree(
                  newIdentNode("layer"),
                  nnkCall.newTree(
                    newIdentNode("maxChunkIdx"),
                    newIdentNode("T")
                  )
                )
              ),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    )
  )
)
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, 8) Error: cannot generate VM code for ==

Stats

  • Started 2023-08-17T01:26:12
  • Finished 2023-08-17T01:26:12
  • Duration

IR

Compiled filesize 0 bytes (0 bytes)

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("log2trunc"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkInfix.newTree(
          newIdentNode("|"),
          newIdentNode("uint64"),
          newIdentNode("uint64")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkIfStmt.newTree(
        nnkElifBranch.newTree(
          nnkInfix.newTree(
            newIdentNode("=="),
            newIdentNode("x"),
            newLit(0)
          ),
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        ),
        nnkElse.newTree(
          nnkStmtList.newTree(
            nnkCall.newTree(
              newIdentNode("int"),
              newLit(0)
            )
          )
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("maxChunkIdx"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int64"),
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newIdentNode("type"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newLit(0)
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("layer"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("vIdx"),
        newIdentNode("int64"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("log2trunc"),
        nnkUInt64Lit.newTree(
        )
      )
    )
  ),
  nnkTemplateDef.newTree(
    newIdentNode("int2"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        newIdentNode("int"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("x")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("HashList"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("indices"),
            nnkBracketExpr.newTree(
              newIdentNode("array"),
              nnkCall.newTree(
                newIdentNode("int"),
                nnkCall.newTree(
                  newIdentNode("layer"),
                  nnkCall.newTree(
                    newIdentNode("maxChunkIdx"),
                    newIdentNode("T")
                  )
                )
              ),
              newIdentNode("int")
            ),
            newEmptyNode()
          )
        )
      )
    )
  )
)
Stats
  • GCC 11.4.0
  • LibC 2.35
  • Valgrind 3.18.1
  • NodeJS 17.1
  • Linux 5.15.0
  • Created 2023-08-17T01:24:48Z
  • 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 48 minutes bisecting 8 commits at 0 commits per second.

@metagn
Copy link
Collaborator

metagn commented Aug 17, 2023

Should be no difference between this and #22490, no? The template indirection is a workaround for generic type bodies eagerly compiling expressions

@tersec
Copy link
Contributor Author

tersec commented Aug 17, 2023

Should be no difference between this and #22490, no? The template indirection is a workaround for generic type bodies eagerly compiling expressions

Sure, one happened to compile before and one didn't, though. But yes, the intent between them is the same.

metagn added a commit to metagn/Nim that referenced this issue Aug 17, 2023
Araq pushed a commit that referenced this issue Aug 17, 2023
narimiran pushed a commit that referenced this issue Apr 17, 2024
fixes #22490, fixes #22491, adapts #22029 to type conversions

(cherry picked from commit 98c39e8)
narimiran pushed a commit that referenced this issue Apr 17, 2024
fixes #22490, fixes #22491, adapts #22029 to type conversions

(cherry picked from commit 98c39e8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants