Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler crash with generics static int, Atomics, range #22922

Open
hugosenari opened this issue Nov 8, 2023 · 3 comments
Open

Compiler crash with generics static int, Atomics, range #22922

hugosenari opened this issue Nov 8, 2023 · 3 comments

Comments

@hugosenari
Copy link

hugosenari commented Nov 8, 2023

Description

Compiler crash with generics static int, Atomics, range

/home/hugosenari/Code/NimCloned/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: field 'intVal' is not accessible for type 'TNode' using 'kind = nkStaticExpr' [FieldDefect]

import std/atomics

type
  R [L: static int] = range[0..L]
  Q [L: static int] = object
    v: Atomic[R[L]]
  
proc f[L: static int](q: Q[L]): void =
  discard

var q: Q[4]
q.f
  

Nim Version

Nim Compiler Version 2.0.0 [Linux: amd64]
Compiled at 2023-11-07
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: a488067

Current Output

/compiler/nim.nim(164) nim
/home/hugosenari/Code/NimCloned/compiler/nim.nim(119) handleCmdLine
/home/hugosenari/Code/NimCloned/compiler/main.nim(307) mainCommand
/home/hugosenari/Code/NimCloned/compiler/main.nim(276) compileToBackend
/home/hugosenari/Code/NimCloned/compiler/main.nim(138) commandCompileToC
/home/hugosenari/Code/NimCloned/compiler/pipelines.nim(294) compilePipelineProject
/home/hugosenari/Code/NimCloned/compiler/pipelines.nim(224) compilePipelineModule
/home/hugosenari/Code/NimCloned/compiler/pipelines.nim(171) processPipelineModule
/home/hugosenari/Code/NimCloned/compiler/sem.nim(782) semWithPContext
/home/hugosenari/Code/NimCloned/compiler/sem.nim(751) semStmtAndGenerateGenerics
/home/hugosenari/Code/NimCloned/compiler/semstmts.nim(2636) semStmt
/home/hugosenari/Code/NimCloned/compiler/semexprs.nim(1160) semExprNoType
/home/hugosenari/Code/NimCloned/compiler/semexprs.nim(3229) semExpr
/home/hugosenari/Code/NimCloned/lib/system.nim(938) semStmtList
/home/hugosenari/Code/NimCloned/compiler/semexprs.nim(3083) semExpr
/home/hugosenari/Code/NimCloned/compiler/semexprs.nim(3123) semExpr
/home/hugosenari/Code/NimCloned/compiler/semexprs.nim(1141) semDirectOp
/home/hugosenari/Code/NimCloned/compiler/semexprs.nim(964) semOverloadedCallAnalyseEffects
/home/hugosenari/Code/NimCloned/compiler/semcall.nim(620) semOverloadedCall
/home/hugosenari/Code/NimCloned/compiler/semcall.nim(419) resolveOverloads
/home/hugosenari/Code/NimCloned/compiler/semcall.nim(95) pickBestCandidate
/home/hugosenari/Code/NimCloned/compiler/sigmatch.nim(2648) matches
/home/hugosenari/Code/NimCloned/compiler/sigmatch.nim(2582) matchesAux
/home/hugosenari/Code/NimCloned/compiler/sigmatch.nim(2287) paramTypesMatch
/home/hugosenari/Code/NimCloned/compiler/sigmatch.nim(2116) paramTypesMatchAux
/home/hugosenari/Code/NimCloned/compiler/sigmatch.nim(1532) typeRel
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(751) prepareMetatypeForSigmatch
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(121) replaceTypeVarsT
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(557) replaceTypeVarsTAux
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(424) handleGenericInvocation
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(121) replaceTypeVarsT
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(651) replaceTypeVarsTAux
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(265) replaceTypeVarsN
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(219) replaceTypeVarsN
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(121) replaceTypeVarsT
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(557) replaceTypeVarsTAux
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(424) handleGenericInvocation
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(121) replaceTypeVarsT
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(651) replaceTypeVarsTAux
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(265) replaceTypeVarsN
/home/hugosenari/Code/NimCloned/compiler/semtypinst.nim(240) replaceTypeVarsN
/home/hugosenari/Code/NimCloned/compiler/sem.nim(372) semConstExpr
/home/hugosenari/Code/NimCloned/compiler/semexprs.nim(119) semExprWithType
/home/hugosenari/Code/NimCloned/compiler/semexprs.nim(78) semExprCheck
/home/hugosenari/Code/NimCloned/compiler/semexprs.nim(3124) semExpr
/home/hugosenari/Code/NimCloned/compiler/semexprs.nim(2406) semMagic
/home/hugosenari/Code/NimCloned/compiler/semexprs.nim(557) semIs
/home/hugosenari/Code/NimCloned/compiler/semexprs.nim(510) isOpImpl
/home/hugosenari/Code/NimCloned/compiler/sigmatch.nim(1620) typeRel
/home/hugosenari/Code/NimCloned/compiler/sigmatch.nim(1073) typeRel
/home/hugosenari/Code/NimCloned/compiler/sigmatch.nim(1179) typeRel
/home/hugosenari/Code/NimCloned/compiler/sigmatch.nim(416) handleRange
/home/hugosenari/Code/NimCloned/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: field 'intVal' is not accessible for type 'TNode' using 'kind = nkStaticExpr' [FieldDefect]

Expected Output

Compiles or Provide a proper error (ie: can't mix static: int and range with)

Possible Solution

No response

Additional Information

No response

@hugosenari hugosenari changed the title Compiler crash due to generics static int, Atomics, range Compiler crash with generics static int, Atomics, range Nov 8, 2023
@ringabout
Copy link
Member

!nim c

import std/atomics

type
  R [L: static int] = range[0..L]
  Q [L: static int] = object
    v: Atomic[R[L]]
  
proc f[L: static int](q: Q[L]): void =
  discard

var q: Q[4]
q.f

Copy link
Contributor

🐧 Linux bisect by @ringabout (member)
devel 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
fatal.nim(53)            sysFatal
Error: unhandled exception: field 'intVal' is not accessible for type 'TNode' using 'kind = nkStaticExpr' [FieldDefect]

IR

Compiled filesize 0 bytes (0 bytes)

Stats

  • Started 2023-11-16T12:34:40
  • Finished 2023-11-16T12:34:40
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("atomics")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("R"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkBracketExpr.newTree(
        newIdentNode("range"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          newIdentNode("L")
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Q"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("v"),
            nnkBracketExpr.newTree(
              newIdentNode("Atomic"),
              nnkBracketExpr.newTree(
                newIdentNode("R"),
                newIdentNode("L")
              )
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("L"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("q"),
        nnkBracketExpr.newTree(
          newIdentNode("Q"),
          newIdentNode("L")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        newEmptyNode()
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("q"),
      nnkBracketExpr.newTree(
        newIdentNode("Q"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkDotExpr.newTree(
    newIdentNode("q"),
    newIdentNode("f")
  )
)
stable 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
fatal.nim(53)            sysFatal
Error: unhandled exception: field 'intVal' is not accessible for type 'TNode' using 'kind = nkStaticExpr' [FieldDefect]

IR

Compiled filesize 0 bytes (0 bytes)

Stats

  • Started 2023-11-16T12:34:41
  • Finished 2023-11-16T12:34:41
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("atomics")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("R"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkBracketExpr.newTree(
        newIdentNode("range"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          newIdentNode("L")
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Q"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("v"),
            nnkBracketExpr.newTree(
              newIdentNode("Atomic"),
              nnkBracketExpr.newTree(
                newIdentNode("R"),
                newIdentNode("L")
              )
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("L"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("q"),
        nnkBracketExpr.newTree(
          newIdentNode("Q"),
          newIdentNode("L")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        newEmptyNode()
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("q"),
      nnkBracketExpr.newTree(
        newIdentNode("Q"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkDotExpr.newTree(
    newIdentNode("q"),
    newIdentNode("f")
  )
)
2.0.0 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
fatal.nim(53)            sysFatal
Error: unhandled exception: field 'intVal' is not accessible for type 'TNode' using 'kind = nkStaticExpr' [FieldDefect]

IR

Compiled filesize 0 bytes (0 bytes)

Stats

  • Started 2023-11-16T12:34:41
  • Finished 2023-11-16T12:34:41
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("atomics")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("R"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkBracketExpr.newTree(
        newIdentNode("range"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          newIdentNode("L")
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Q"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("v"),
            nnkBracketExpr.newTree(
              newIdentNode("Atomic"),
              nnkBracketExpr.newTree(
                newIdentNode("R"),
                newIdentNode("L")
              )
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("L"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("q"),
        nnkBracketExpr.newTree(
          newIdentNode("Q"),
          newIdentNode("L")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        newEmptyNode()
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("q"),
      nnkBracketExpr.newTree(
        newIdentNode("Q"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkDotExpr.newTree(
    newIdentNode("q"),
    newIdentNode("f")
  )
)
1.6.14 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
fatal.nim(54)            sysFatal
Error: unhandled exception: field 'intVal' is not accessible for type 'TNode' using 'kind = nkStaticExpr' [FieldDefect]

IR

Compiled filesize 0 bytes (0 bytes)

Stats

  • Started 2023-11-16T12:34:44
  • Finished 2023-11-16T12:34:44
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("atomics")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("R"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkBracketExpr.newTree(
        newIdentNode("range"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          newIdentNode("L")
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Q"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("v"),
            nnkBracketExpr.newTree(
              newIdentNode("Atomic"),
              nnkBracketExpr.newTree(
                newIdentNode("R"),
                newIdentNode("L")
              )
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("L"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("q"),
        nnkBracketExpr.newTree(
          newIdentNode("Q"),
          newIdentNode("L")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        newEmptyNode()
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("q"),
      nnkBracketExpr.newTree(
        newIdentNode("Q"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkDotExpr.newTree(
    newIdentNode("q"),
    newIdentNode("f")
  )
)
1.4.8 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
fatal.nim(49)            sysFatal
Error: unhandled exception: 'intVal' is not accessible using discriminant 'kind' of type 'TNode' [FieldDefect]

IR

Compiled filesize 0 bytes (0 bytes)

Stats

  • Started 2023-11-16T12:34:47
  • Finished 2023-11-16T12:34:47
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("atomics")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("R"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkBracketExpr.newTree(
        newIdentNode("range"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          newIdentNode("L")
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Q"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("v"),
            nnkBracketExpr.newTree(
              newIdentNode("Atomic"),
              nnkBracketExpr.newTree(
                newIdentNode("R"),
                newIdentNode("L")
              )
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("L"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("q"),
        nnkBracketExpr.newTree(
          newIdentNode("Q"),
          newIdentNode("L")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        newEmptyNode()
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("q"),
      nnkBracketExpr.newTree(
        newIdentNode("Q"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkDotExpr.newTree(
    newIdentNode("q"),
    newIdentNode("f")
  )
)
1.2.18 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
fatal.nim(49)            sysFatal
Error: unhandled exception: 'intVal' is not accessible using discriminant 'kind' of type 'TNode' [FieldError]

IR

Compiled filesize 0 bytes (0 bytes)

Stats

  • Started 2023-11-16T12:34:49
  • Finished 2023-11-16T12:34:49
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("atomics")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("R"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkBracketExpr.newTree(
        newIdentNode("range"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          newIdentNode("L")
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Q"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("v"),
            nnkBracketExpr.newTree(
              newIdentNode("Atomic"),
              nnkBracketExpr.newTree(
                newIdentNode("R"),
                newIdentNode("L")
              )
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("L"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("q"),
        nnkBracketExpr.newTree(
          newIdentNode("Q"),
          newIdentNode("L")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        newEmptyNode()
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("q"),
      nnkBracketExpr.newTree(
        newIdentNode("Q"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkDotExpr.newTree(
    newIdentNode("q"),
    newIdentNode("f")
  )
)
1.0.10 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
fatal.nim(39)            sysFatal
Error: unhandled exception: 'intVal' is not accessible using discriminant 'kind' of type 'TNode' [FieldError]

IR

Compiled filesize 0 bytes (0 bytes)

Stats

  • Started 2023-11-16T12:34:51
  • Finished 2023-11-16T12:34:51
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("atomics")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("R"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkBracketExpr.newTree(
        newIdentNode("range"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          newIdentNode("L")
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Q"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("L"),
          nnkCommand.newTree(
            newIdentNode("static"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("v"),
            nnkBracketExpr.newTree(
              newIdentNode("Atomic"),
              nnkBracketExpr.newTree(
                newIdentNode("R"),
                newIdentNode("L")
              )
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("L"),
        nnkCommand.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("void"),
      nnkIdentDefs.newTree(
        newIdentNode("q"),
        nnkBracketExpr.newTree(
          newIdentNode("Q"),
          newIdentNode("L")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        newEmptyNode()
      )
    )
  ),
  nnkVarSection.newTree(
    nnkIdentDefs.newTree(
      newIdentNode("q"),
      nnkBracketExpr.newTree(
        newIdentNode("Q"),
        newLit(4)
      ),
      newEmptyNode()
    )
  ),
  nnkDotExpr.newTree(
    newIdentNode("q"),
    newIdentNode("f")
  )
)
Stats
  • GCC 11.4.0
  • Clang 14.0.0
  • NodeJS 18.2
  • Created 2023-11-16T12:34:15Z
  • Comments 1
  • Commands nim c --run -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints: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 14 minutes bisecting 7 commits at 0 commits per second

@metagn
Copy link
Collaborator

metagn commented Oct 14, 2024

The nkStaticExpr does not get properly instantiated during overload resolution because of cl.allowMetaTypes, after #24098 or #24086 this code could be changed to unconditionally semExpr

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

No branches or pull requests

4 participants