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

std/json JsonNode == operator raises exception #22253

Closed
tersec opened this issue Jul 11, 2023 · 2 comments · Fixed by #22294
Closed

std/json JsonNode == operator raises exception #22253

tersec opened this issue Jul 11, 2023 · 2 comments · Fixed by #22294
Assignees

Comments

@tersec
Copy link
Contributor

tersec commented Jul 11, 2023

Description

from std/json import JsonNode, `==`
proc f() {.raises: [].} = discard default(JsonNode) == nil

Nim Version

Nim Compiler Version 1.6.14 [Linux: amd64]
Compiled at 2023-06-29
Copyright (c) 2006-2023 by Andreas Rumpf

active boot switches: -d:release

version-2-0:

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

git hash: 9ddd768cce291e5c562cde23baeeefb47aa79c86
active boot switches: -d:release

devel:

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

git hash: 9ddd768cce291e5c562cde23baeeefb47aa79c86
active boot switches: -d:release

Current Output

1.6.14:

Error: default(JsonNode) == nil can raise an unlisted exception: ref KeyError

version-2-0 and devel:

Error: default(JsonNode) == nil can raise an unlisted exception: Exception

Expected Output

No exception raised in `==` for `JsonNode`

Possible Solution

No response

Additional Information

No response

@juancarlospaco
Copy link
Collaborator

!nim c

from std/json import JsonNode, `==`
proc f() {.raises: [].} = discard default(JsonNode) == nil

@github-actions
Copy link
Contributor

@juancarlospaco (contributor)

devel :-1: FAIL

Output

Error: Command failed: nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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, 53) Error: default(JsonNode) == nil can raise an unlisted exception: Exception

Stats

  • Created 2023-07-11T13:41:52Z
  • Started 2023-07-11T13:42:27
  • Finished 2023-07-11T13:42:28
  • Duration 1 minute
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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

IR

AST

nnkStmtList.newTree(
  nnkFromStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("json")
    ),
    newIdentNode("JsonNode"),
    nnkAccQuoted.newTree(
      newIdentNode("==")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("raises"),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        nnkInfix.newTree(
          newIdentNode("=="),
          nnkCall.newTree(
            newIdentNode("default"),
            newIdentNode("JsonNode")
          ),
          newNilLit()
        )
      )
    )
  )
)
stable :-1: FAIL

Output

Error: Command failed: nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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, 53) Error: default(JsonNode) == nil can raise an unlisted exception: ref KeyError

Stats

  • Created 2023-07-11T13:41:52Z
  • Started 2023-07-11T13:42:28
  • Finished 2023-07-11T13:42:29
  • Duration 1 minute
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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

IR

AST

nnkStmtList.newTree(
  nnkFromStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("json")
    ),
    newIdentNode("JsonNode"),
    nnkAccQuoted.newTree(
      newIdentNode("==")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("raises"),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        nnkInfix.newTree(
          newIdentNode("=="),
          nnkCall.newTree(
            newIdentNode("default"),
            newIdentNode("JsonNode")
          ),
          newNilLit()
        )
      )
    )
  )
)
1.6.0 :-1: FAIL

Output

Error: Command failed: nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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, 53) Error: default(JsonNode) == nil can raise an unlisted exception: ref KeyError

Stats

  • Created 2023-07-11T13:41:52Z
  • Started 2023-07-11T13:42:32
  • Finished 2023-07-11T13:42:33
  • Duration 1 minute
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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

IR

AST

nnkStmtList.newTree(
  nnkFromStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("json")
    ),
    newIdentNode("JsonNode"),
    nnkAccQuoted.newTree(
      newIdentNode("==")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("raises"),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        nnkInfix.newTree(
          newIdentNode("=="),
          nnkCall.newTree(
            newIdentNode("default"),
            newIdentNode("JsonNode")
          ),
          newNilLit()
        )
      )
    )
  )
)
1.4.0 :-1: FAIL

Output

Error: Command failed: nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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, 53) Error: can raise an unlisted exception: ref KeyError

Stats

  • Created 2023-07-11T13:41:52Z
  • Started 2023-07-11T13:42:36
  • Finished 2023-07-11T13:42:37
  • Duration 1 minute
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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

IR

AST

nnkStmtList.newTree(
  nnkFromStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("json")
    ),
    newIdentNode("JsonNode"),
    nnkAccQuoted.newTree(
      newIdentNode("==")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("raises"),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        nnkInfix.newTree(
          newIdentNode("=="),
          nnkCall.newTree(
            newIdentNode("default"),
            newIdentNode("JsonNode")
          ),
          newNilLit()
        )
      )
    )
  )
)
1.2.0 :-1: FAIL

Output

Error: Command failed: nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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, 53) Error: can raise an unlisted exception: ref KeyError

Stats

  • Created 2023-07-11T13:41:52Z
  • Started 2023-07-11T13:42:52
  • Finished 2023-07-11T13:42:53
  • Duration now
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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

IR

AST

nnkStmtList.newTree(
  nnkFromStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("json")
    ),
    newIdentNode("JsonNode"),
    nnkAccQuoted.newTree(
      newIdentNode("==")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("raises"),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        nnkInfix.newTree(
          newIdentNode("=="),
          nnkCall.newTree(
            newIdentNode("default"),
            newIdentNode("JsonNode")
          ),
          newNilLit()
        )
      )
    )
  )
)
1.0.0 :-1: FAIL

Output

Error: Command failed: nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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, 20) template/generic instantiation from here
/home/runner/.choosenim/toolchains/nim-1.0.0/lib/pure/collections/tables.nim(263, 7) Error: can raise an unlisted exception: ref KeyError

Stats

  • Created 2023-07-11T13:41:52Z
  • Started 2023-07-11T13:43:06
  • Finished 2023-07-11T13:43:06
  • Duration now
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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

IR

AST

nnkStmtList.newTree(
  nnkFromStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("json")
    ),
    newIdentNode("JsonNode"),
    nnkAccQuoted.newTree(
      newIdentNode("==")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("raises"),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        nnkInfix.newTree(
          newIdentNode("=="),
          nnkCall.newTree(
            newIdentNode("default"),
            newIdentNode("JsonNode")
          ),
          newNilLit()
        )
      )
    )
  )
)
0.20.2 :-1: FAIL

Output

Error: Command failed: nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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, 20) template/generic instantiation from here
/home/runner/.choosenim/toolchains/nim-0.20.2/lib/pure/collections/tables.nim(263, 7) Error: can raise an unlisted exception: ref KeyError

Stats

  • Created 2023-07-11T13:41:52Z
  • Started 2023-07-11T13:43:17
  • Finished 2023-07-11T13:43:18
  • Duration 1 minute
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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

IR

AST

nnkStmtList.newTree(
  nnkFromStmt.newTree(
    nnkInfix.newTree(
      newIdentNode("/"),
      newIdentNode("std"),
      newIdentNode("json")
    ),
    newIdentNode("JsonNode"),
    nnkAccQuoted.newTree(
      newIdentNode("==")
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("f"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    nnkPragma.newTree(
      nnkExprColonExpr.newTree(
        newIdentNode("raises"),
        nnkBracket.newTree(
        )
      )
    ),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkDiscardStmt.newTree(
        nnkInfix.newTree(
          newIdentNode("=="),
          nnkCall.newTree(
            newIdentNode("default"),
            newIdentNode("JsonNode")
          ),
          newNilLit()
        )
      )
    )
  )
)
🤖 Bug found in 54 minutes bisecting 7 commits at 0 commits per second.

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