nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.56k stars 1.47k forks source link

Inheritance of type in generics passes type constraint but fails in execution #23908

Open itspomf opened 3 months ago

itspomf commented 3 months ago

Description

I'm using the playground to try to test out the creation of a simple entity-component relational model in Nim, using generics.

The following code example shows the situation and the test scenario of assigning a single component to an entity.

import std/tables
import std/sequtils

type
  Component* = object of RootObj
  Subtree[T] = OrderedTableRef[ typedesc[T], seq[T] ]

let universe = newOrderedTable[ string, Subtree[ Component ]]()

proc drop*[T: Component]( uuid: string, components: seq[T] ) =
  universe.withValue( uuid, branch ):
    branch.withValue( T, leaf ):
      for component in components:
        leaf.del( component )

proc put*[T: Component]( uuid: string, components: seq[T] ) =
  let branch = universe.mgetOrPut( uuid, Subtree[T]() ) # <-- fails here!
  if not branch.hasKey( T ):
    branch[T] = components
  else:
    branch.withValue( T, leaf ):
      for component in components:
        if component notin leaf:
          leaf.add( component )

# TESTS FOLLOW

type 
  Dummy = object of Component
    value: int

echo "Creating dummy component ..."
let d0 = Dummy( value: 0 )
echo $d0

echo "Performing insert on 'zero' ..."
put("zero", @[ d0 ])
echo "Done."

Nim Version

Using "latest" (via NimPlayground)

Current Output

/usercode/in.nim(46, 4) template/generic instantiation of `put` from here
/usercode/in.nim(17, 24) Error: type mismatch
Expression: mgetOrPut(universe, uuid, Subtree[T]())
  [1] universe: OrderedTableRef[system.string, Subtree[in.Component]]
  [2] uuid: string
  [3] Subtree[T](): Subtree[in.Dummy]

Expected one of (first mismatch at [position]):
[1] proc mgetOrPut[A, B](t: TableRef[A, B]; key: A; val: B): var B
[1] proc mgetOrPut[A, B](t: var OrderedTable[A, B]; key: A; val: B): var B
[1] proc mgetOrPut[A, B](t: var Table[A, B]; key: A; val: B): var B
[3] proc mgetOrPut[A, B](t: OrderedTableRef[A, B]; key: A; val: B): var B

Expected Output

Creating dummy component ...
<some instance of Dummy>
Performing insert on 'zero' ...
Done.

Possible Solution

No response

Additional Information

As best I can tell from the debugger's output, it's correctly recognizing that I wish to create a Subtree of Dummy (position 3), but fails to assert that Dummy is an object of Component, despite passing the constraint of [T: Component] to reach line 17.

Since the currently available documentation on the nim-lang.org site does not provide guidance on inheritance in generics (or how to explicitly declare this via a type constraint), I would assume that this should resolve normally.

Searching the bug list, this might be related to #88.

juancarlospaco commented 3 months ago

!nim c

import std/tables
import std/sequtils

type
  Component* = object of RootObj
  Subtree[T] = OrderedTableRef[ typedesc[T], seq[T] ]

let universe = newOrderedTable[ string, Subtree[ Component ]]()

proc drop*[T: Component]( uuid: string, components: seq[T] ) =
  universe.withValue( uuid, branch ):
    branch.withValue( T, leaf ):
      for component in components:
        leaf.del( component )

proc put*[T: Component]( uuid: string, components: seq[T] ) =
  let branch = universe.mgetOrPut( uuid, Subtree[T]() )
  if not branch.hasKey( T ):
    branch[T] = components
  else:
    branch.withValue( T, leaf ):
      for component in components:
        if component notin leaf:
          leaf.add( component )

type 
  Dummy = object of Component
    value: int

let d0 = Dummy( value: 0 )
echo $d0
put("zero", @[ d0 ])
github-actions[bot] commented 3 months ago
:penguin: Linux bisect by @juancarlospaco (collaborator)
devel :-1: 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(26, 4) template/generic instantiation of `put` from here /home/runner/work/Nim/Nim/temp.nim(13, 24) Error: type mismatch Expression: mgetOrPut(universe, uuid, Subtree[T]()) [1] universe: OrderedTableRef[system.string, Subtree[temp.Component]] [2] uuid: string [3] Subtree[T](): Subtree[temp.Dummy] Expected one of (first mismatch at [position]): [1] proc mgetOrPut[A, B](t: TableRef[A, B]; key: A): var B [1] proc mgetOrPut[A, B](t: TableRef[A, B]; key: A; val: B): var B [1] proc mgetOrPut[A, B](t: var OrderedTable[A, B]; key: A): var B [1] proc mgetOrPut[A, B](t: var OrderedTable[A, B]; key: A; val: B): var B [1] proc mgetOrPut[A, B](t: var Table[A, B]; key: A): var B [1] proc mgetOrPut[A, B](t: var Table[A, B]; key: A; val: B): var B [3] proc mgetOrPut[A, B](t: OrderedTableRef[A, B]; key: A): var B extra argument given [3] proc mgetOrPut[A, B](t: OrderedTableRef[A, B]; key: A; val: B): var B assertions.nim(34) raiseAssert Error: unhandled exception: errGenerated [AssertionDefect] ```

IR

Compiled filesize 0 (0 bytes) ```cpp ```

Stats

  • Started 2024-07-31T20:22:36
  • Finished 2024-07-31T20:22:37
  • Duration

AST

```nim nnkStmtList.newTree( nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("tables") ) ), nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("sequtils") ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("Component") ), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("RootObj") ), newEmptyNode() ) ), nnkTypeDef.newTree( newIdentNode("Subtree"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), nnkBracketExpr.newTree( newIdentNode("OrderedTableRef"), nnkBracketExpr.newTree( newIdentNode("typedesc"), newIdentNode("T") ), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("universe"), newEmptyNode(), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("newOrderedTable"), newIdentNode("string"), nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("Component") ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("drop") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("withValue") ), newIdentNode("uuid"), newIdentNode("branch"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("del") ), newIdentNode("component") ) ) ) ) ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("put") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("branch"), newEmptyNode(), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("mgetOrPut") ), newIdentNode("uuid"), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("T") ) ) ) ) ), nnkIfStmt.newTree( nnkElifBranch.newTree( nnkPrefix.newTree( newIdentNode("not"), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("hasKey") ), newIdentNode("T") ) ), nnkStmtList.newTree( nnkAsgn.newTree( nnkBracketExpr.newTree( newIdentNode("branch"), newIdentNode("T") ), newIdentNode("components") ) ) ), nnkElse.newTree( nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkIfStmt.newTree( nnkElifBranch.newTree( nnkInfix.newTree( newIdentNode("notin"), newIdentNode("component"), newIdentNode("leaf") ), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("add") ), newIdentNode("component") ) ) ) ) ) ) ) ) ) ) ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Dummy"), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("Component") ), nnkRecList.newTree( nnkIdentDefs.newTree( newIdentNode("value"), newIdentNode("int"), newEmptyNode() ) ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("d0"), newEmptyNode(), nnkObjConstr.newTree( newIdentNode("Dummy"), nnkExprColonExpr.newTree( newIdentNode("value"), newLit(0) ) ) ) ), nnkCommand.newTree( newIdentNode("echo"), nnkPrefix.newTree( newIdentNode("$"), newIdentNode("d0") ) ), nnkCall.newTree( newIdentNode("put"), newLit("zero"), nnkPrefix.newTree( newIdentNode("@"), nnkBracket.newTree( newIdentNode("d0") ) ) ) ) ```
stable :-1: 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(26, 4) template/generic instantiation of `put` from here /home/runner/work/Nim/Nim/temp.nim(13, 24) Error: type mismatch Expression: mgetOrPut(universe, uuid, Subtree[T]()) [1] universe: OrderedTableRef[system.string, Subtree[temp.Component]] [2] uuid: string [3] Subtree[T](): Subtree[temp.Dummy] Expected one of (first mismatch at [position]): [1] proc mgetOrPut[A, B](t: TableRef[A, B]; key: A; val: B): var B [1] proc mgetOrPut[A, B](t: var OrderedTable[A, B]; key: A; val: B): var B [1] proc mgetOrPut[A, B](t: var Table[A, B]; key: A; val: B): var B [3] proc mgetOrPut[A, B](t: OrderedTableRef[A, B]; key: A; val: B): var B assertions.nim(34) raiseAssert Error: unhandled exception: options.nim(682, 5) `false` errGenerated [AssertionDefect] ```

IR

Compiled filesize 0 (0 bytes) ```cpp ```

Stats

  • Started 2024-07-31T20:22:41
  • Finished 2024-07-31T20:22:41
  • Duration

AST

```nim nnkStmtList.newTree( nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("tables") ) ), nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("sequtils") ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("Component") ), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("RootObj") ), newEmptyNode() ) ), nnkTypeDef.newTree( newIdentNode("Subtree"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), nnkBracketExpr.newTree( newIdentNode("OrderedTableRef"), nnkBracketExpr.newTree( newIdentNode("typedesc"), newIdentNode("T") ), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("universe"), newEmptyNode(), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("newOrderedTable"), newIdentNode("string"), nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("Component") ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("drop") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("withValue") ), newIdentNode("uuid"), newIdentNode("branch"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("del") ), newIdentNode("component") ) ) ) ) ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("put") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("branch"), newEmptyNode(), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("mgetOrPut") ), newIdentNode("uuid"), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("T") ) ) ) ) ), nnkIfStmt.newTree( nnkElifBranch.newTree( nnkPrefix.newTree( newIdentNode("not"), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("hasKey") ), newIdentNode("T") ) ), nnkStmtList.newTree( nnkAsgn.newTree( nnkBracketExpr.newTree( newIdentNode("branch"), newIdentNode("T") ), newIdentNode("components") ) ) ), nnkElse.newTree( nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkIfStmt.newTree( nnkElifBranch.newTree( nnkInfix.newTree( newIdentNode("notin"), newIdentNode("component"), newIdentNode("leaf") ), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("add") ), newIdentNode("component") ) ) ) ) ) ) ) ) ) ) ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Dummy"), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("Component") ), nnkRecList.newTree( nnkIdentDefs.newTree( newIdentNode("value"), newIdentNode("int"), newEmptyNode() ) ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("d0"), newEmptyNode(), nnkObjConstr.newTree( newIdentNode("Dummy"), nnkExprColonExpr.newTree( newIdentNode("value"), newLit(0) ) ) ) ), nnkCommand.newTree( newIdentNode("echo"), nnkPrefix.newTree( newIdentNode("$"), newIdentNode("d0") ) ), nnkCall.newTree( newIdentNode("put"), newLit("zero"), nnkPrefix.newTree( newIdentNode("@"), nnkBracket.newTree( newIdentNode("d0") ) ) ) ) ```
2.0.4 :-1: 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(26, 4) template/generic instantiation of `put` from here /home/runner/work/Nim/Nim/temp.nim(13, 24) Error: type mismatch Expression: mgetOrPut(universe, uuid, Subtree[T]()) [1] universe: OrderedTableRef[system.string, Subtree[temp.Component]] [2] uuid: string [3] Subtree[T](): Subtree[temp.Dummy] Expected one of (first mismatch at [position]): [1] proc mgetOrPut[A, B](t: TableRef[A, B]; key: A; val: B): var B [1] proc mgetOrPut[A, B](t: var OrderedTable[A, B]; key: A; val: B): var B [1] proc mgetOrPut[A, B](t: var Table[A, B]; key: A; val: B): var B [3] proc mgetOrPut[A, B](t: OrderedTableRef[A, B]; key: A; val: B): var B assertions.nim(34) raiseAssert Error: unhandled exception: options.nim(681, 5) `false` errGenerated [AssertionDefect] ```

IR

Compiled filesize 0 (0 bytes) ```cpp ```

Stats

  • Started 2024-07-31T20:22:44
  • Finished 2024-07-31T20:22:44
  • Duration

AST

```nim nnkStmtList.newTree( nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("tables") ) ), nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("sequtils") ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("Component") ), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("RootObj") ), newEmptyNode() ) ), nnkTypeDef.newTree( newIdentNode("Subtree"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), nnkBracketExpr.newTree( newIdentNode("OrderedTableRef"), nnkBracketExpr.newTree( newIdentNode("typedesc"), newIdentNode("T") ), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("universe"), newEmptyNode(), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("newOrderedTable"), newIdentNode("string"), nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("Component") ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("drop") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("withValue") ), newIdentNode("uuid"), newIdentNode("branch"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("del") ), newIdentNode("component") ) ) ) ) ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("put") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("branch"), newEmptyNode(), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("mgetOrPut") ), newIdentNode("uuid"), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("T") ) ) ) ) ), nnkIfStmt.newTree( nnkElifBranch.newTree( nnkPrefix.newTree( newIdentNode("not"), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("hasKey") ), newIdentNode("T") ) ), nnkStmtList.newTree( nnkAsgn.newTree( nnkBracketExpr.newTree( newIdentNode("branch"), newIdentNode("T") ), newIdentNode("components") ) ) ), nnkElse.newTree( nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkIfStmt.newTree( nnkElifBranch.newTree( nnkInfix.newTree( newIdentNode("notin"), newIdentNode("component"), newIdentNode("leaf") ), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("add") ), newIdentNode("component") ) ) ) ) ) ) ) ) ) ) ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Dummy"), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("Component") ), nnkRecList.newTree( nnkIdentDefs.newTree( newIdentNode("value"), newIdentNode("int"), newEmptyNode() ) ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("d0"), newEmptyNode(), nnkObjConstr.newTree( newIdentNode("Dummy"), nnkExprColonExpr.newTree( newIdentNode("value"), newLit(0) ) ) ) ), nnkCommand.newTree( newIdentNode("echo"), nnkPrefix.newTree( newIdentNode("$"), newIdentNode("d0") ) ), nnkCall.newTree( newIdentNode("put"), newLit("zero"), nnkPrefix.newTree( newIdentNode("@"), nnkBracket.newTree( newIdentNode("d0") ) ) ) ) ```
2.0.0 :-1: 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(26, 4) template/generic instantiation of `put` from here /home/runner/work/Nim/Nim/temp.nim(13, 24) Error: type mismatch Expression: mgetOrPut(universe, uuid, Subtree[T]()) [1] universe: OrderedTableRef[system.string, Subtree[temp.Component]] [2] uuid: string [3] Subtree[T](): Subtree[temp.Dummy] Expected one of (first mismatch at [position]): [1] proc mgetOrPut[A, B](t: TableRef[A, B]; key: A; val: B): var B [1] proc mgetOrPut[A, B](t: var OrderedTable[A, B]; key: A; val: B): var B [1] proc mgetOrPut[A, B](t: var Table[A, B]; key: A; val: B): var B [3] proc mgetOrPut[A, B](t: OrderedTableRef[A, B]; key: A; val: B): var B assertions.nim(34) raiseAssert Error: unhandled exception: options.nim(664, 5) `false` errGenerated [AssertionDefect] ```

IR

Compiled filesize 0 (0 bytes) ```cpp ```

Stats

  • Started 2024-07-31T20:22:48
  • Finished 2024-07-31T20:22:48
  • Duration

AST

```nim nnkStmtList.newTree( nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("tables") ) ), nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("sequtils") ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("Component") ), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("RootObj") ), newEmptyNode() ) ), nnkTypeDef.newTree( newIdentNode("Subtree"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), nnkBracketExpr.newTree( newIdentNode("OrderedTableRef"), nnkBracketExpr.newTree( newIdentNode("typedesc"), newIdentNode("T") ), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("universe"), newEmptyNode(), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("newOrderedTable"), newIdentNode("string"), nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("Component") ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("drop") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("withValue") ), newIdentNode("uuid"), newIdentNode("branch"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("del") ), newIdentNode("component") ) ) ) ) ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("put") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("branch"), newEmptyNode(), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("mgetOrPut") ), newIdentNode("uuid"), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("T") ) ) ) ) ), nnkIfStmt.newTree( nnkElifBranch.newTree( nnkPrefix.newTree( newIdentNode("not"), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("hasKey") ), newIdentNode("T") ) ), nnkStmtList.newTree( nnkAsgn.newTree( nnkBracketExpr.newTree( newIdentNode("branch"), newIdentNode("T") ), newIdentNode("components") ) ) ), nnkElse.newTree( nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkIfStmt.newTree( nnkElifBranch.newTree( nnkInfix.newTree( newIdentNode("notin"), newIdentNode("component"), newIdentNode("leaf") ), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("add") ), newIdentNode("component") ) ) ) ) ) ) ) ) ) ) ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Dummy"), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("Component") ), nnkRecList.newTree( nnkIdentDefs.newTree( newIdentNode("value"), newIdentNode("int"), newEmptyNode() ) ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("d0"), newEmptyNode(), nnkObjConstr.newTree( newIdentNode("Dummy"), nnkExprColonExpr.newTree( newIdentNode("value"), newLit(0) ) ) ) ), nnkCommand.newTree( newIdentNode("echo"), nnkPrefix.newTree( newIdentNode("$"), newIdentNode("d0") ) ), nnkCall.newTree( newIdentNode("put"), newLit("zero"), nnkPrefix.newTree( newIdentNode("@"), nnkBracket.newTree( newIdentNode("d0") ) ) ) ) ```
1.6.20 :-1: 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(26, 4) template/generic instantiation of `put` from here /home/runner/work/Nim/Nim/temp.nim(13, 24) Error: type mismatch: got but expected one of: proc mgetOrPut[A, B](t: OrderedTableRef[A, B]; key: A; val: B): var B first type mismatch at position: 3 required type for val: B but expression 'Subtree[T]()' is of type: Subtree[temp.Dummy] 3 other mismatching symbols have been suppressed; compile with --showAllMismatches:on to see them expression: mgetOrPut(universe, uuid, Subtree[T]()) fatal.nim(54) sysFatal Error: unhandled exception: options.nim(662, 14) `false` errGenerated [AssertionDefect] ```

IR

Compiled filesize 0 (0 bytes) ```cpp ```

Stats

  • Started 2024-07-31T20:22:50
  • Finished 2024-07-31T20:22:51
  • Duration

AST

```nim nnkStmtList.newTree( nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("tables") ) ), nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("sequtils") ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("Component") ), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("RootObj") ), newEmptyNode() ) ), nnkTypeDef.newTree( newIdentNode("Subtree"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), nnkBracketExpr.newTree( newIdentNode("OrderedTableRef"), nnkBracketExpr.newTree( newIdentNode("typedesc"), newIdentNode("T") ), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("universe"), newEmptyNode(), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("newOrderedTable"), newIdentNode("string"), nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("Component") ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("drop") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("withValue") ), newIdentNode("uuid"), newIdentNode("branch"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("del") ), newIdentNode("component") ) ) ) ) ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("put") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("branch"), newEmptyNode(), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("mgetOrPut") ), newIdentNode("uuid"), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("T") ) ) ) ) ), nnkIfStmt.newTree( nnkElifBranch.newTree( nnkPrefix.newTree( newIdentNode("not"), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("hasKey") ), newIdentNode("T") ) ), nnkStmtList.newTree( nnkAsgn.newTree( nnkBracketExpr.newTree( newIdentNode("branch"), newIdentNode("T") ), newIdentNode("components") ) ) ), nnkElse.newTree( nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkIfStmt.newTree( nnkElifBranch.newTree( nnkInfix.newTree( newIdentNode("notin"), newIdentNode("component"), newIdentNode("leaf") ), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("add") ), newIdentNode("component") ) ) ) ) ) ) ) ) ) ) ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Dummy"), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("Component") ), nnkRecList.newTree( nnkIdentDefs.newTree( newIdentNode("value"), newIdentNode("int"), newEmptyNode() ) ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("d0"), newEmptyNode(), nnkObjConstr.newTree( newIdentNode("Dummy"), nnkExprColonExpr.newTree( newIdentNode("value"), newLit(0) ) ) ) ), nnkCommand.newTree( newIdentNode("echo"), nnkPrefix.newTree( newIdentNode("$"), newIdentNode("d0") ) ), nnkCall.newTree( newIdentNode("put"), newLit("zero"), nnkPrefix.newTree( newIdentNode("@"), nnkBracket.newTree( newIdentNode("d0") ) ) ) ) ```
1.4.8 :-1: 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(26, 4) template/generic instantiation of `put` from here /home/runner/work/Nim/Nim/temp.nim(13, 24) Error: type mismatch: got but expected one of: proc mgetOrPut[A, B](t: OrderedTableRef[A, B]; key: A; val: B): var B first type mismatch at position: 3 required type for val: B but expression 'Subtree[T]()' is of type: Subtree[temp.Dummy] 3 other mismatching symbols have been suppressed; compile with --showAllMismatches:on to see them expression: mgetOrPut(universe, uuid, Subtree[T]()) ```

IR

Compiled filesize 0 (0 bytes) ```cpp ```

Stats

  • Started 2024-07-31T20:22:53
  • Finished 2024-07-31T20:22:53
  • Duration

AST

```nim nnkStmtList.newTree( nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("tables") ) ), nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("sequtils") ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("Component") ), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("RootObj") ), newEmptyNode() ) ), nnkTypeDef.newTree( newIdentNode("Subtree"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), nnkBracketExpr.newTree( newIdentNode("OrderedTableRef"), nnkBracketExpr.newTree( newIdentNode("typedesc"), newIdentNode("T") ), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("universe"), newEmptyNode(), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("newOrderedTable"), newIdentNode("string"), nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("Component") ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("drop") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("withValue") ), newIdentNode("uuid"), newIdentNode("branch"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("del") ), newIdentNode("component") ) ) ) ) ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("put") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("branch"), newEmptyNode(), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("mgetOrPut") ), newIdentNode("uuid"), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("T") ) ) ) ) ), nnkIfStmt.newTree( nnkElifBranch.newTree( nnkPrefix.newTree( newIdentNode("not"), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("hasKey") ), newIdentNode("T") ) ), nnkStmtList.newTree( nnkAsgn.newTree( nnkBracketExpr.newTree( newIdentNode("branch"), newIdentNode("T") ), newIdentNode("components") ) ) ), nnkElse.newTree( nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkIfStmt.newTree( nnkElifBranch.newTree( nnkInfix.newTree( newIdentNode("notin"), newIdentNode("component"), newIdentNode("leaf") ), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("add") ), newIdentNode("component") ) ) ) ) ) ) ) ) ) ) ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Dummy"), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("Component") ), nnkRecList.newTree( nnkIdentDefs.newTree( newIdentNode("value"), newIdentNode("int"), newEmptyNode() ) ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("d0"), newEmptyNode(), nnkObjConstr.newTree( newIdentNode("Dummy"), nnkExprColonExpr.newTree( newIdentNode("value"), newLit(0) ) ) ) ), nnkCommand.newTree( newIdentNode("echo"), nnkPrefix.newTree( newIdentNode("$"), newIdentNode("d0") ) ), nnkCall.newTree( newIdentNode("put"), newLit("zero"), nnkPrefix.newTree( newIdentNode("@"), nnkBracket.newTree( newIdentNode("d0") ) ) ) ) ```
1.2.18 :-1: 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(26, 4) template/generic instantiation of `put` from here /home/runner/work/Nim/Nim/temp.nim(13, 24) Error: type mismatch: got but expected one of: proc mgetOrPut[A, B](t: OrderedTableRef[A, B]; key: A; val: B): var B first type mismatch at position: 3 required type for val: B but expression 'Subtree[T]()' is of type: Subtree[temp.Dummy] 3 other mismatching symbols have been suppressed; compile with --showAllMismatches:on to see them expression: mgetOrPut(universe, uuid, Subtree[T]()) ```

IR

Compiled filesize 0 (0 bytes) ```cpp ```

Stats

  • Started 2024-07-31T20:22:56
  • Finished 2024-07-31T20:22:56
  • Duration

AST

```nim nnkStmtList.newTree( nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("tables") ) ), nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("sequtils") ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("Component") ), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("RootObj") ), newEmptyNode() ) ), nnkTypeDef.newTree( newIdentNode("Subtree"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), nnkBracketExpr.newTree( newIdentNode("OrderedTableRef"), nnkBracketExpr.newTree( newIdentNode("typedesc"), newIdentNode("T") ), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("universe"), newEmptyNode(), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("newOrderedTable"), newIdentNode("string"), nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("Component") ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("drop") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("withValue") ), newIdentNode("uuid"), newIdentNode("branch"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("del") ), newIdentNode("component") ) ) ) ) ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("put") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("branch"), newEmptyNode(), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("mgetOrPut") ), newIdentNode("uuid"), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("T") ) ) ) ) ), nnkIfStmt.newTree( nnkElifBranch.newTree( nnkPrefix.newTree( newIdentNode("not"), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("hasKey") ), newIdentNode("T") ) ), nnkStmtList.newTree( nnkAsgn.newTree( nnkBracketExpr.newTree( newIdentNode("branch"), newIdentNode("T") ), newIdentNode("components") ) ) ), nnkElse.newTree( nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkIfStmt.newTree( nnkElifBranch.newTree( nnkInfix.newTree( newIdentNode("notin"), newIdentNode("component"), newIdentNode("leaf") ), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("add") ), newIdentNode("component") ) ) ) ) ) ) ) ) ) ) ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Dummy"), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("Component") ), nnkRecList.newTree( nnkIdentDefs.newTree( newIdentNode("value"), newIdentNode("int"), newEmptyNode() ) ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("d0"), newEmptyNode(), nnkObjConstr.newTree( newIdentNode("Dummy"), nnkExprColonExpr.newTree( newIdentNode("value"), newLit(0) ) ) ) ), nnkCommand.newTree( newIdentNode("echo"), nnkPrefix.newTree( newIdentNode("$"), newIdentNode("d0") ) ), nnkCall.newTree( newIdentNode("put"), newLit("zero"), nnkPrefix.newTree( newIdentNode("@"), nnkBracket.newTree( newIdentNode("d0") ) ) ) ) ```
1.0.10 :-1: 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(26, 4) template/generic instantiation of `put` from here /home/runner/work/Nim/Nim/temp.nim(13, 24) Error: type mismatch: got but expected one of: proc mgetOrPut[A, B](t: OrderedTableRef[A, B]; key: A; val: B): var B first type mismatch at position: 3 required type for val: B but expression 'Subtree[T]()' is of type: Subtree[temp.Dummy] 3 other mismatching symbols have been suppressed; compile with --showAllMismatches:on to see them expression: mgetOrPut(universe, uuid, Subtree[T]()) ```

IR

Compiled filesize 0 (0 bytes) ```cpp ```

Stats

  • Started 2024-07-31T20:22:58
  • Finished 2024-07-31T20:22:58
  • Duration

AST

```nim nnkStmtList.newTree( nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("tables") ) ), nnkImportStmt.newTree( nnkInfix.newTree( newIdentNode("/"), newIdentNode("std"), newIdentNode("sequtils") ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("Component") ), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("RootObj") ), newEmptyNode() ) ), nnkTypeDef.newTree( newIdentNode("Subtree"), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newEmptyNode(), newEmptyNode() ) ), nnkBracketExpr.newTree( newIdentNode("OrderedTableRef"), nnkBracketExpr.newTree( newIdentNode("typedesc"), newIdentNode("T") ), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("universe"), newEmptyNode(), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("newOrderedTable"), newIdentNode("string"), nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("Component") ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("drop") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("withValue") ), newIdentNode("uuid"), newIdentNode("branch"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("del") ), newIdentNode("component") ) ) ) ) ) ) ) ) ), nnkProcDef.newTree( nnkPostfix.newTree( newIdentNode("*"), newIdentNode("put") ), newEmptyNode(), nnkGenericParams.newTree( nnkIdentDefs.newTree( newIdentNode("T"), newIdentNode("Component"), newEmptyNode() ) ), nnkFormalParams.newTree( newEmptyNode(), nnkIdentDefs.newTree( newIdentNode("uuid"), newIdentNode("string"), newEmptyNode() ), nnkIdentDefs.newTree( newIdentNode("components"), nnkBracketExpr.newTree( newIdentNode("seq"), newIdentNode("T") ), newEmptyNode() ) ), newEmptyNode(), newEmptyNode(), nnkStmtList.newTree( nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("branch"), newEmptyNode(), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("universe"), newIdentNode("mgetOrPut") ), newIdentNode("uuid"), nnkCall.newTree( nnkBracketExpr.newTree( newIdentNode("Subtree"), newIdentNode("T") ) ) ) ) ), nnkIfStmt.newTree( nnkElifBranch.newTree( nnkPrefix.newTree( newIdentNode("not"), nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("hasKey") ), newIdentNode("T") ) ), nnkStmtList.newTree( nnkAsgn.newTree( nnkBracketExpr.newTree( newIdentNode("branch"), newIdentNode("T") ), newIdentNode("components") ) ) ), nnkElse.newTree( nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("branch"), newIdentNode("withValue") ), newIdentNode("T"), newIdentNode("leaf"), nnkStmtList.newTree( nnkForStmt.newTree( newIdentNode("component"), newIdentNode("components"), nnkStmtList.newTree( nnkIfStmt.newTree( nnkElifBranch.newTree( nnkInfix.newTree( newIdentNode("notin"), newIdentNode("component"), newIdentNode("leaf") ), nnkStmtList.newTree( nnkCall.newTree( nnkDotExpr.newTree( newIdentNode("leaf"), newIdentNode("add") ), newIdentNode("component") ) ) ) ) ) ) ) ) ) ) ) ) ), nnkTypeSection.newTree( nnkTypeDef.newTree( newIdentNode("Dummy"), newEmptyNode(), nnkObjectTy.newTree( newEmptyNode(), nnkOfInherit.newTree( newIdentNode("Component") ), nnkRecList.newTree( nnkIdentDefs.newTree( newIdentNode("value"), newIdentNode("int"), newEmptyNode() ) ) ) ) ), nnkLetSection.newTree( nnkIdentDefs.newTree( newIdentNode("d0"), newEmptyNode(), nnkObjConstr.newTree( newIdentNode("Dummy"), nnkExprColonExpr.newTree( newIdentNode("value"), newLit(0) ) ) ) ), nnkCommand.newTree( newIdentNode("echo"), nnkPrefix.newTree( newIdentNode("$"), newIdentNode("d0") ) ), nnkCall.newTree( newIdentNode("put"), newLit("zero"), nnkPrefix.newTree( newIdentNode("@"), nnkBracket.newTree( newIdentNode("d0") ) ) ) ) ```
Stats
  • GCC 11.4.0
  • Clang 14.0.0
  • NodeJS 20.4
  • Created 2024-07-31T20:22:09Z
  • 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

:robot: Bug found in 25 minutes bisecting 8 commits at 0 commits per second