GithubHelp home page GithubHelp logo

Enum Overloading Regression? about nim HOT 4 CLOSED

c-blake avatar c-blake commented on June 11, 2024
Enum Overloading Regression?

from nim.

Comments (4)

juancarlospaco avatar juancarlospaco commented on June 11, 2024 2

!nim c

import std/heapqueue
type Algo = enum heapqueue, quick
proc bar*(algo=quick) =
  var x: HeapQueue[int]
  case algo
  of heapqueue: echo 1
  of quick: echo 2
  echo x.len

from nim.

github-actions avatar github-actions commented on June 11, 2024 1
🐧 Linux bisect by @juancarlospaco (collaborator)
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
/home/runner/work/Nim/Nim/temp.nim(6, 6) Error: expression 'heapqueue' has no type (or is ambiguous)
assertions.nim(34)       raiseAssert
Error: unhandled exception: errGenerated [AssertionDefect]

IR

Compiled filesize 0 bytes (0 bytes)

Stats

  • Started 2024-05-11T13:52:10
  • Finished 2024-05-11T13:52:11
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("heapqueue")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Algo"),
      newEmptyNode(),
      nnkEnumTy.newTree(
        newEmptyNode(),
        newIdentNode("heapqueue"),
        newIdentNode("quick")
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      newIdentNode("bar")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("algo"),
        newEmptyNode(),
        newIdentNode("quick")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("x"),
          nnkBracketExpr.newTree(
            newIdentNode("HeapQueue"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkCaseStmt.newTree(
        newIdentNode("algo"),
        nnkOfBranch.newTree(
          newIdentNode("heapqueue"),
          nnkStmtList.newTree(
            nnkCommand.newTree(
              newIdentNode("echo"),
              newLit(1)
            )
          )
        ),
        nnkOfBranch.newTree(
          newIdentNode("quick"),
          nnkStmtList.newTree(
            nnkCommand.newTree(
              newIdentNode("echo"),
              newLit(2)
            )
          )
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkDotExpr.newTree(
          newIdentNode("x"),
          newIdentNode("len")
        )
      )
    )
  )
)
stable 👍 OK

Output


IR

Compiled filesize 90.64 Kb (92,816 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
 void (*volatile inner)(void);
 inner = PreMainInner;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
 (*inner)();
#else
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
 PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 (*inner)();
#else
 PreMain();
 NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
 cmdLine = args;
 cmdCount = argc;
 gEnv = env;
 NimMain();
 return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
 nimTestErrorFlag();
}
}

Stats

  • Started 2024-05-11T13:52:11
  • Finished 2024-05-11T13:52:12
  • Duration
2.0.4 👍 OK

Output


IR

Compiled filesize 90.64 Kb (92,816 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
 void (*volatile inner)(void);
 inner = PreMainInner;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
 (*inner)();
#else
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
 PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 (*inner)();
#else
 PreMain();
 NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
 cmdLine = args;
 cmdCount = argc;
 gEnv = env;
 NimMain();
 return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
 nimTestErrorFlag();
}
}

Stats

  • Started 2024-05-11T13:52:12
  • Finished 2024-05-11T13:52:12
  • Duration
1.6.20 👎 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
/home/runner/work/Nim/Nim/temp.nim(2, 18) Error: redefinition of 'heapqueue'; previous declaration here: /home/runner/work/Nim/Nim/temp.nim(1, 11)
fatal.nim(54)            sysFatal
Error: unhandled exception: options.nim(662, 14) `false` errGenerated [AssertionDefect]

IR

Compiled filesize 90.64 Kb (92,816 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
 void (*volatile inner)(void);
 inner = PreMainInner;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
 (*inner)();
#else
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
 PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 (*inner)();
#else
 PreMain();
 NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
 cmdLine = args;
 cmdCount = argc;
 gEnv = env;
 NimMain();
 return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
 nimTestErrorFlag();
}
}

Stats

  • Started 2024-05-11T13:52:15
  • Finished 2024-05-11T13:52:15
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("heapqueue")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Algo"),
      newEmptyNode(),
      nnkEnumTy.newTree(
        newEmptyNode(),
        newIdentNode("heapqueue"),
        newIdentNode("quick")
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      newIdentNode("bar")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("algo"),
        newEmptyNode(),
        newIdentNode("quick")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("x"),
          nnkBracketExpr.newTree(
            newIdentNode("HeapQueue"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkCaseStmt.newTree(
        newIdentNode("algo"),
        nnkOfBranch.newTree(
          newIdentNode("heapqueue"),
          nnkStmtList.newTree(
            nnkCommand.newTree(
              newIdentNode("echo"),
              newLit(1)
            )
          )
        ),
        nnkOfBranch.newTree(
          newIdentNode("quick"),
          nnkStmtList.newTree(
            nnkCommand.newTree(
              newIdentNode("echo"),
              newLit(2)
            )
          )
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkDotExpr.newTree(
          newIdentNode("x"),
          newIdentNode("len")
        )
      )
    )
  )
)
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
/home/runner/work/Nim/Nim/temp.nim(2, 18) Error: redefinition of 'heapqueue'; previous declaration here: /home/runner/.choosenim/toolchains/nim-1.4.8/lib/pure/collections/heapqueue.nim(1, 2)

IR

Compiled filesize 90.64 Kb (92,816 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
 void (*volatile inner)(void);
 inner = PreMainInner;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
 (*inner)();
#else
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
 PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 (*inner)();
#else
 PreMain();
 NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
 cmdLine = args;
 cmdCount = argc;
 gEnv = env;
 NimMain();
 return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
 nimTestErrorFlag();
}
}

Stats

  • Started 2024-05-11T13:52:17
  • Finished 2024-05-11T13:52:18
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("heapqueue")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Algo"),
      newEmptyNode(),
      nnkEnumTy.newTree(
        newEmptyNode(),
        newIdentNode("heapqueue"),
        newIdentNode("quick")
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      newIdentNode("bar")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("algo"),
        newEmptyNode(),
        newIdentNode("quick")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("x"),
          nnkBracketExpr.newTree(
            newIdentNode("HeapQueue"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkCaseStmt.newTree(
        newIdentNode("algo"),
        nnkOfBranch.newTree(
          newIdentNode("heapqueue"),
          nnkStmtList.newTree(
            nnkCommand.newTree(
              newIdentNode("echo"),
              newLit(1)
            )
          )
        ),
        nnkOfBranch.newTree(
          newIdentNode("quick"),
          nnkStmtList.newTree(
            nnkCommand.newTree(
              newIdentNode("echo"),
              newLit(2)
            )
          )
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkDotExpr.newTree(
          newIdentNode("x"),
          newIdentNode("len")
        )
      )
    )
  )
)
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
/home/runner/work/Nim/Nim/temp.nim(2, 18) Error: redefinition of 'heapqueue'; previous declaration here: /home/runner/.choosenim/toolchains/nim-1.2.18/lib/pure/collections/heapqueue.nim(1, 2)

IR

Compiled filesize 90.64 Kb (92,816 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
 void (*volatile inner)(void);
 inner = PreMainInner;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
 (*inner)();
#else
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
 PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 (*inner)();
#else
 PreMain();
 NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
 cmdLine = args;
 cmdCount = argc;
 gEnv = env;
 NimMain();
 return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
 nimTestErrorFlag();
}
}

Stats

  • Started 2024-05-11T13:52:20
  • Finished 2024-05-11T13:52:20
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("heapqueue")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Algo"),
      newEmptyNode(),
      nnkEnumTy.newTree(
        newEmptyNode(),
        newIdentNode("heapqueue"),
        newIdentNode("quick")
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      newIdentNode("bar")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("algo"),
        newEmptyNode(),
        newIdentNode("quick")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("x"),
          nnkBracketExpr.newTree(
            newIdentNode("HeapQueue"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkCaseStmt.newTree(
        newIdentNode("algo"),
        nnkOfBranch.newTree(
          newIdentNode("heapqueue"),
          nnkStmtList.newTree(
            nnkCommand.newTree(
              newIdentNode("echo"),
              newLit(1)
            )
          )
        ),
        nnkOfBranch.newTree(
          newIdentNode("quick"),
          nnkStmtList.newTree(
            nnkCommand.newTree(
              newIdentNode("echo"),
              newLit(2)
            )
          )
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkDotExpr.newTree(
          newIdentNode("x"),
          newIdentNode("len")
        )
      )
    )
  )
)
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
/home/runner/work/Nim/Nim/temp.nim(2, 18) Error: redefinition of 'heapqueue'; previous declaration here: /home/runner/.choosenim/toolchains/nim-1.0.10/lib/pure/collections/heapqueue.nim(1, 2)

IR

Compiled filesize 90.64 Kb (92,816 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
#if 0
 void (*volatile inner)(void);
 inner = PreMainInner;
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
 (*inner)();
#else
 atmdotdotatsdotdotatsdotdotatsdotchoosenimatstoolchainsatsnimminus2dot0dot4atslibatssystemdotnim_Init000();
 PreMainInner();
#endif
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
#if 0
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 (*inner)();
#else
 PreMain();
 NimMainInner();
#endif
}
int main(int argc, char** args, char** env) {
 cmdLine = args;
 cmdCount = argc;
 gEnv = env;
 NimMain();
 return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
 nimTestErrorFlag();
}
}

Stats

  • Started 2024-05-11T13:52:22
  • Finished 2024-05-11T13:52:22
  • Duration

AST

nnkStmtList.newTree(
  nnkImportStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("heapqueue")
    )
  ),
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Algo"),
      newEmptyNode(),
      nnkEnumTy.newTree(
        newEmptyNode(),
        newIdentNode("heapqueue"),
        newIdentNode("quick")
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      newIdentNode("bar")
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("algo"),
        newEmptyNode(),
        newIdentNode("quick")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("x"),
          nnkBracketExpr.newTree(
            newIdentNode("HeapQueue"),
            newIdentNode("int")
          ),
          newEmptyNode()
        )
      ),
      nnkCaseStmt.newTree(
        newIdentNode("algo"),
        nnkOfBranch.newTree(
          newIdentNode("heapqueue"),
          nnkStmtList.newTree(
            nnkCommand.newTree(
              newIdentNode("echo"),
              newLit(1)
            )
          )
        ),
        nnkOfBranch.newTree(
          newIdentNode("quick"),
          nnkStmtList.newTree(
            nnkCommand.newTree(
              newIdentNode("echo"),
              newLit(2)
            )
          )
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        nnkDotExpr.newTree(
          newIdentNode("x"),
          newIdentNode("len")
        )
      )
    )
  )
)
#c101490a0 ➡️ 🐛

Diagnostics

metagn introduced a bug at 2024-05-10 11:30:57 +0300 on commit #c101490a0 with message:

remove bad type inference behavior for enum identifiers (#23588)

refs
https://github.com/nim-lang/Nim/issues/23586#issuecomment-2102113750

In #20091 a bad kind of type inference was mistakenly left in where if
an identifier `abc` had an expected type of an enum type `Enum`, and
`Enum` had a member called `abc`, the identifier would change to be that
enum member. This causes bugs where a local symbol can have the same
name as an enum member but have a different value. I had assumed this
behavior was removed since but it wasn't, and CI seems to pass having it
removed.

A separate PR needs to be made for the 2.0 branch because these lines
were moved around during a refactoring in #23123 which is not in 2.0.

The bug is in the files:

compiler/semexprs.nim
tests/lookups/tenumlocalsym.nim

The bug can be in the commits:

(Diagnostics sometimes off-by-one).

Stats
  • GCC 11.4.0
  • Clang 14.0.0
  • NodeJS 20.2
  • Created 2024-05-11T13:51:41Z
  • 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 54 minutes bisecting 606 commits at 11 commits per second

from nim.

metagn avatar metagn commented on June 11, 2024 1

Pre-existing in general:

import std/heapqueue
proc heapqueue(x: int) = discard
# or type Algo = enum heapqueue
let x = heapqueue

A non-pre-existing version would be:

import std/heapqueue
type Algo = enum heapqueue, quick
let x: Algo = heapqueue # note type annotation

We could disable module symbols in any context where a value is expected but in foo.bar the compiler expects foo to have a type. Maybe foo.bar should be a specific context where module symbols are allowed? But this could break code like:

macro foo(x: typed) = discard

import math
foo(math)

Something that has a better chance of working is not giving module symbols "priority" in symbol lookup (don't break in searchInScopesFilterBy) because they don't check for overloads so they would be treated as ambiguous and get resolved away but this isn't reliable because the order in which the symbols are imported/declared would affect it.

from nim.

juancarlospaco avatar juancarlospaco commented on June 11, 2024

@metagn See Bisect.

from nim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.