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

Recursive concept that has a function with the same name as an existing one causes compiler to read from nil #24039

Open
fabricio-p opened this issue Sep 1, 2024 · 3 comments

Comments

@fabricio-p
Copy link

Description

proc x(y: int): string = discard

type
  C = concept
    proc x(y: C): int
  A[T: C] = tuple
    x: T
  B*[T: C] = object
    a: A[T]

Nim Version

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

git hash: 5935c3b
active boot switches:

Current Output

Hint: used config file '/home/fabricio/projects/third-party/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/fabricio/projects/third-party/Nim/config/config.nims' [Conf]
......................................................................Traceback (most recent call last)
/home/fabricio/projects/third-party/Nim/compiler/nim.nim(164) nim
/home/fabricio/projects/third-party/Nim/compiler/nim.nim(119) handleCmdLine
/home/fabricio/projects/third-party/Nim/compiler/main.nim(307) mainCommand
/home/fabricio/projects/third-party/Nim/compiler/main.nim(276) compileToBackend
/home/fabricio/projects/third-party/Nim/compiler/main.nim(138) commandCompileToC
/home/fabricio/projects/third-party/Nim/compiler/pipelines.nim(299) compilePipelineProject
/home/fabricio/projects/third-party/Nim/compiler/pipelines.nim(226) compilePipelineModule
/home/fabricio/projects/third-party/Nim/compiler/pipelines.nim(173) processPipelineModule
/home/fabricio/projects/third-party/Nim/compiler/sem.nim(867) semWithPContext
/home/fabricio/projects/third-party/Nim/compiler/sem.nim(836) semStmtAndGenerateGenerics
/home/fabricio/projects/third-party/Nim/compiler/semstmts.nim(2689) semStmt
/home/fabricio/projects/third-party/Nim/compiler/semexprs.nim(1182) semExprNoType
/home/fabricio/projects/third-party/Nim/compiler/semexprs.nim(3323) semExpr /home/fabricio/projects/nim/bug.nim(1, 1) nkStmtList
/home/fabricio/projects/third-party/Nim/lib/system.nim(937) semStmtList
/home/fabricio/projects/third-party/Nim/compiler/semexprs.nim(3328) semExpr /home/fabricio/projects/nim/bug.nim(4, 3) nkTypeSection
/home/fabricio/projects/third-party/Nim/compiler/semstmts.nim(1673) semTypeSection
/home/fabricio/projects/third-party/Nim/compiler/semstmts.nim(1442) typeSectionRightSidePass
/home/fabricio/projects/third-party/Nim/compiler/semtypes.nim(2139) semTypeNode
/home/fabricio/projects/third-party/Nim/compiler/semtypes.nim(965) semObjectNode
/home/fabricio/projects/third-party/Nim/compiler/semtypes.nim(812) semRecordNodeAux
/home/fabricio/projects/third-party/Nim/compiler/semtypes.nim(828) semRecordNodeAux
/home/fabricio/projects/third-party/Nim/compiler/semtypes.nim(2066) semTypeNode
/home/fabricio/projects/third-party/Nim/compiler/semtypes.nim(1563) semGeneric
/home/fabricio/projects/third-party/Nim/compiler/sigmatch.nim(2702) matches
/home/fabricio/projects/third-party/Nim/compiler/sigmatch.nim(2642) matchesAux
/home/fabricio/projects/third-party/Nim/compiler/sigmatch.nim(2347) paramTypesMatch
/home/fabricio/projects/third-party/Nim/compiler/sigmatch.nim(2177) paramTypesMatchAux
/home/fabricio/projects/third-party/Nim/compiler/sigmatch.nim(1787) typeRel
/home/fabricio/projects/third-party/Nim/compiler/sigmatch.nim(1743) typeRel
/home/fabricio/projects/third-party/Nim/compiler/concepts.nim(325) conceptMatch
/home/fabricio/projects/third-party/Nim/compiler/concepts.nim(290) conceptMatchNode
/home/fabricio/projects/third-party/Nim/compiler/concepts.nim(298) conceptMatchNode
/home/fabricio/projects/third-party/Nim/compiler/concepts.nim(281) matchSyms
/home/fabricio/projects/third-party/Nim/compiler/concepts.nim(256) matchSym
/home/fabricio/projects/third-party/Nim/compiler/concepts.nim(182) matchType
/home/fabricio/projects/third-party/Nim/compiler/ast.nim lastSon
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Expected Output

Hint: used config file '/home/fabricio/projects/third-party/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/fabricio/projects/third-party/Nim/config/config.nims' [Conf]
......................................................................
CC: ../third-party/Nim/lib/system/exceptions.nim
CC: ../third-party/Nim/lib/std/private/since.nim
CC: ../third-party/Nim/lib/system/ctypes.nim
CC: ../third-party/Nim/lib/std/sysatomics.nim
CC: ../third-party/Nim/lib/system/ansi_c.nim
CC: ../third-party/Nim/lib/system/memory.nim
CC: ../third-party/Nim/lib/std/private/syslocks.nim
CC: ../third-party/Nim/lib/std/private/threadtypes.nim
CC: ../third-party/Nim/lib/std/private/digitsutils.nim
CC: ../third-party/Nim/lib/std/private/miscdollars.nim
CC: ../third-party/Nim/lib/std/assertions.nim
CC: ../third-party/Nim/lib/system/iterators.nim
CC: ../third-party/Nim/lib/system/coro_detection.nim
CC: ../third-party/Nim/lib/std/private/dragonbox.nim
CC: ../third-party/Nim/lib/std/private/schubfach.nim
CC: ../third-party/Nim/lib/std/formatfloat.nim
CC: ../third-party/Nim/lib/std/objectdollar.nim
CC: ../third-party/Nim/lib/system/dollars.nim
CC: ../third-party/Nim/lib/std/typedthreads.nim
CC: ../third-party/Nim/lib/system/stacktraces.nim
CC: ../third-party/Nim/lib/std/private/bitops_utils.nim
CC: ../third-party/Nim/lib/system/countbits_impl.nim
CC: ../third-party/Nim/lib/system/repr_v2.nim
CC: ../third-party/Nim/lib/std/widestrs.nim
CC: ../third-party/Nim/lib/std/syncio.nim
CC: ../third-party/Nim/lib/system.nim
CC: bug.nim
Hint:  [Link]
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
27785 lines; 1.420s; 30.406MiB peakmem; proj: /home/fabricio/projects/nim/bug.nim; out: /home/fabricio/.cache/nim/bug_d/bug_39498606B2F6B94C1188035595434CAE17A4CF94 [SuccessX]
Hint: /home/fabricio/.cache/nim/bug_d/bug_39498606B2F6B94C1188035595434CAE17A4CF94 [Exec]

Known Workarounds

No response

Additional Information

No response

@juancarlospaco
Copy link
Collaborator

!nim c

proc x(y: int): string = discard

type
  C = concept
    proc x(y: C): int
  A[T: C] = tuple
    x: T
  B*[T: C] = object
    a: A[T]

Copy link
Contributor

github-actions bot commented Sep 1, 2024

🐧 Linux bisect by @juancarlospaco (collaborator)
devel 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-09-01T16:11:04
  • Finished 2024-09-01T16:11:04
  • Duration

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("x"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("y"),
        newIdentNode("int"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        newEmptyNode()
      )
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("C"),
      newEmptyNode(),
      nnkTypeClassTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode(),
        nnkStmtList.newTree(
          nnkProcDef.newTree(
            newIdentNode("x"),
            newEmptyNode(),
            newEmptyNode(),
            nnkFormalParams.newTree(
              newIdentNode("int"),
              nnkIdentDefs.newTree(
                newIdentNode("y"),
                newIdentNode("C"),
                newEmptyNode()
              )
            ),
            newEmptyNode(),
            newEmptyNode(),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("A"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newIdentNode("C"),
          newEmptyNode()
        )
      ),
      nnkTupleTy.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("x"),
          newIdentNode("T"),
          newEmptyNode()
        )
      )
    ),
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("B")
      ),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newIdentNode("C"),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("a"),
            nnkBracketExpr.newTree(
              newIdentNode("A"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    )
  )
)
stable 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-09-01T16:11:08
  • Finished 2024-09-01T16:11:09
  • Duration

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("x"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("y"),
        newIdentNode("int"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        newEmptyNode()
      )
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("C"),
      newEmptyNode(),
      nnkTypeClassTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode(),
        nnkStmtList.newTree(
          nnkProcDef.newTree(
            newIdentNode("x"),
            newEmptyNode(),
            newEmptyNode(),
            nnkFormalParams.newTree(
              newIdentNode("int"),
              nnkIdentDefs.newTree(
                newIdentNode("y"),
                newIdentNode("C"),
                newEmptyNode()
              )
            ),
            newEmptyNode(),
            newEmptyNode(),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("A"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newIdentNode("C"),
          newEmptyNode()
        )
      ),
      nnkTupleTy.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("x"),
          newIdentNode("T"),
          newEmptyNode()
        )
      )
    ),
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("B")
      ),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newIdentNode("C"),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("a"),
            nnkBracketExpr.newTree(
              newIdentNode("A"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    )
  )
)
2.0.8 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-09-01T16:11:09
  • Finished 2024-09-01T16:11:09
  • Duration

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("x"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("y"),
        newIdentNode("int"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        newEmptyNode()
      )
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("C"),
      newEmptyNode(),
      nnkTypeClassTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode(),
        nnkStmtList.newTree(
          nnkProcDef.newTree(
            newIdentNode("x"),
            newEmptyNode(),
            newEmptyNode(),
            nnkFormalParams.newTree(
              newIdentNode("int"),
              nnkIdentDefs.newTree(
                newIdentNode("y"),
                newIdentNode("C"),
                newEmptyNode()
              )
            ),
            newEmptyNode(),
            newEmptyNode(),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("A"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newIdentNode("C"),
          newEmptyNode()
        )
      ),
      nnkTupleTy.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("x"),
          newIdentNode("T"),
          newEmptyNode()
        )
      )
    ),
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("B")
      ),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newIdentNode("C"),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("a"),
            nnkBracketExpr.newTree(
              newIdentNode("A"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    )
  )
)
2.0.0 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-09-01T16:11:13
  • Finished 2024-09-01T16:11:13
  • Duration

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("x"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("y"),
        newIdentNode("int"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        newEmptyNode()
      )
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("C"),
      newEmptyNode(),
      nnkTypeClassTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode(),
        nnkStmtList.newTree(
          nnkProcDef.newTree(
            newIdentNode("x"),
            newEmptyNode(),
            newEmptyNode(),
            nnkFormalParams.newTree(
              newIdentNode("int"),
              nnkIdentDefs.newTree(
                newIdentNode("y"),
                newIdentNode("C"),
                newEmptyNode()
              )
            ),
            newEmptyNode(),
            newEmptyNode(),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("A"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newIdentNode("C"),
          newEmptyNode()
        )
      ),
      nnkTupleTy.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("x"),
          newIdentNode("T"),
          newEmptyNode()
        )
      )
    ),
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("B")
      ),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newIdentNode("C"),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("a"),
            nnkBracketExpr.newTree(
              newIdentNode("A"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    )
  )
)
1.6.20 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-09-01T16:11:16
  • Finished 2024-09-01T16:11:16
  • Duration

AST

nnkStmtList.newTree(
  nnkProcDef.newTree(
    newIdentNode("x"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("y"),
        newIdentNode("int"),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        newEmptyNode()
      )
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("C"),
      newEmptyNode(),
      nnkTypeClassTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        newEmptyNode(),
        nnkStmtList.newTree(
          nnkProcDef.newTree(
            newIdentNode("x"),
            newEmptyNode(),
            newEmptyNode(),
            nnkFormalParams.newTree(
              newIdentNode("int"),
              nnkIdentDefs.newTree(
                newIdentNode("y"),
                newIdentNode("C"),
                newEmptyNode()
              )
            ),
            newEmptyNode(),
            newEmptyNode(),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("A"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newIdentNode("C"),
          newEmptyNode()
        )
      ),
      nnkTupleTy.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("x"),
          newIdentNode("T"),
          newEmptyNode()
        )
      )
    ),
    nnkTypeDef.newTree(
      nnkPostfix.newTree(
        newIdentNode("*"),
        newIdentNode("B")
      ),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newIdentNode("C"),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("a"),
            nnkBracketExpr.newTree(
              newIdentNode("A"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    )
  )
)
1.4.8 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-09-01T16:11:18
  • Finished 2024-09-01T16:11:18
  • Duration

AST

1.2.18 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-09-01T16:11:21
  • Finished 2024-09-01T16:11:21
  • Duration

AST

1.0.10 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-09-01T16:11:24
  • Finished 2024-09-01T16:11:24
  • Duration

AST

Stats
  • GCC 11.4.0
  • Clang 14.0.0
  • NodeJS 20.4
  • Created 2024-09-01T16:10:36Z
  • 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 22 mins bisecting 8 commits at 0 commits per second

@Araq
Copy link
Member

Araq commented Sep 2, 2024

Use Self.

@ringabout ringabout added Invalid Code Acceptance Everything related to compiler not complaining about invalid code Error Messages and removed Invalid Code Acceptance Everything related to compiler not complaining about invalid code labels Sep 2, 2024
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

5 participants