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

GeneriC $ proc fails to resolve #24022

Closed
Clonkk opened this issue Aug 28, 2024 · 4 comments
Closed

GeneriC $ proc fails to resolve #24022

Clonkk opened this issue Aug 28, 2024 · 4 comments

Comments

@Clonkk
Copy link
Contributor

Clonkk commented Aug 28, 2024

Description

type
  Foo[T] = object
    el: seq[T]

  Bar[T] = object
    el: seq[T]

proc `$`*[T](x: Foo[T]) : string =
  result = "bar: " 
  let maxIdx = len(x.el)
  for i in 0..maxIdx-1:
    let e = x.el[i] 
    result.add $(e)
    if i < len-1:
      result.add ", " 

proc `$`*(x: Bar[auto]) : string =
  result = "bar: " 
  let maxIdx = len(x.el)
  for i in 0..maxIdx-1:
    let e = x.el[i] 
    result.add $(e)
    if i < len-1:
      result.add ", " 

proc main() = 
  var f = Foo[float](el: @[25.5])
  var b = Bar[float](el: @[25.5])
  echo f
  echo b

when isMainModule:
  main()

Nim Version

Tested on :

Nim Compiler Version 2.0.8 [MacOSX: arm64]
Compiled at 2024-07-03
Copyright (c) 2006-2023 by Andreas Rumpf

active boot switches: -d:release -d:nimUseLinenoise

And :

Nim Compiler Version 2.1.99 [MacOSX: arm64]
Compiled at 2024-08-28
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 540b414c861c44be9011336ee5fb1cd6f0d6da44
active boot switches: -d:release

Current Output

Expression: echo f
  [1] f: Foo[system.float]

Expected one of (first mismatch at [position]):
[1] proc echo(x: varargs[typed, `$`])


### Expected Output

```text
Should compile fine

Possible Solution

No response

Additional Information

No response

@Clonkk
Copy link
Contributor Author

Clonkk commented Aug 28, 2024

!nim cpp --gc:arc

type
  Foo[T] = object
    el: seq[T]

  Bar[T] = object
    el: seq[T]

proc `$`*[T](x: Foo[T]) : string =
  result = "bar: " 
  let maxIdx = len(x.el)
  for i in 0..maxIdx-1:
    let e = x.el[i] 
    result.add $(e)
    if i < len-1:
      result.add ", " 

proc `$`*(x: Bar[auto]) : string =
  result = "bar: " 
  let maxIdx = len(x.el)
  for i in 0..maxIdx-1:
    let e = x.el[i] 
    result.add $(e)
    if i < len-1:
      result.add ", " 

proc main() = 
  var f = Foo[float](el: @[25.5])
  var b = Bar[float](el: @[25.5])
  echo f
  echo b

when isMainModule:
  main()

Copy link
Contributor

🐧 Linux bisect by @Clonkk (contributor)
devel 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-08-28T09:01:32
  • Finished 2024-08-28T09:01:32
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Foo"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Bar"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Foo"),
          newIdentNode("T")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Bar"),
          newIdentNode("auto")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("main"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("f"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Foo"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("b"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Bar"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("f")
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("b")
      )
    )
  ),
  nnkWhenStmt.newTree(
    nnkElifBranch.newTree(
      newIdentNode("isMainModule"),
      nnkStmtList.newTree(
        nnkCall.newTree(
          newIdentNode("main")
        )
      )
    )
  )
)
stable 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-08-28T09:01:36
  • Finished 2024-08-28T09:01:36
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Foo"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Bar"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Foo"),
          newIdentNode("T")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Bar"),
          newIdentNode("auto")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("main"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("f"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Foo"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("b"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Bar"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("f")
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("b")
      )
    )
  ),
  nnkWhenStmt.newTree(
    nnkElifBranch.newTree(
      newIdentNode("isMainModule"),
      nnkStmtList.newTree(
        nnkCall.newTree(
          newIdentNode("main")
        )
      )
    )
  )
)
2.0.8 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-08-28T09:01:36
  • Finished 2024-08-28T09:01:37
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Foo"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Bar"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Foo"),
          newIdentNode("T")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Bar"),
          newIdentNode("auto")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("main"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("f"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Foo"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("b"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Bar"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("f")
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("b")
      )
    )
  ),
  nnkWhenStmt.newTree(
    nnkElifBranch.newTree(
      newIdentNode("isMainModule"),
      nnkStmtList.newTree(
        nnkCall.newTree(
          newIdentNode("main")
        )
      )
    )
  )
)
2.0.0 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-08-28T09:01:40
  • Finished 2024-08-28T09:01:41
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Foo"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Bar"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Foo"),
          newIdentNode("T")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Bar"),
          newIdentNode("auto")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("main"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("f"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Foo"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("b"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Bar"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("f")
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("b")
      )
    )
  ),
  nnkWhenStmt.newTree(
    nnkElifBranch.newTree(
      newIdentNode("isMainModule"),
      nnkStmtList.newTree(
        nnkCall.newTree(
          newIdentNode("main")
        )
      )
    )
  )
)
1.6.20 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-08-28T09:01:44
  • Finished 2024-08-28T09:01:44
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Foo"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Bar"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Foo"),
          newIdentNode("T")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Bar"),
          newIdentNode("auto")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("main"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("f"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Foo"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("b"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Bar"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("f")
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("b")
      )
    )
  ),
  nnkWhenStmt.newTree(
    nnkElifBranch.newTree(
      newIdentNode("isMainModule"),
      nnkStmtList.newTree(
        nnkCall.newTree(
          newIdentNode("main")
        )
      )
    )
  )
)
1.4.8 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-08-28T09:01:47
  • Finished 2024-08-28T09:01:47
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Foo"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Bar"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Foo"),
          newIdentNode("T")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Bar"),
          newIdentNode("auto")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("main"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("f"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Foo"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("b"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Bar"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("f")
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("b")
      )
    )
  ),
  nnkWhenStmt.newTree(
    nnkElifBranch.newTree(
      newIdentNode("isMainModule"),
      nnkStmtList.newTree(
        nnkCall.newTree(
          newIdentNode("main")
        )
      )
    )
  )
)
1.2.18 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-08-28T09:01:50
  • Finished 2024-08-28T09:01:50
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Foo"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Bar"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Foo"),
          newIdentNode("T")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Bar"),
          newIdentNode("auto")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("main"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("f"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Foo"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("b"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Bar"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("f")
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("b")
      )
    )
  ),
  nnkWhenStmt.newTree(
    nnkElifBranch.newTree(
      newIdentNode("isMainModule"),
      nnkStmtList.newTree(
        nnkCall.newTree(
          newIdentNode("main")
        )
      )
    )
  )
)
1.0.10 👎 FAIL

Output


IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-08-28T09:01:53
  • Finished 2024-08-28T09:01:53
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Foo"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("Bar"),
      nnkGenericParams.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("T"),
          newEmptyNode(),
          newEmptyNode()
        )
      ),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("el"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("T")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    nnkGenericParams.newTree(
      nnkIdentDefs.newTree(
        newIdentNode("T"),
        newEmptyNode(),
        newEmptyNode()
      )
    ),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Foo"),
          newIdentNode("T")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    nnkPostfix.newTree(
      newIdentNode("*"),
      nnkAccQuoted.newTree(
        newIdentNode("$")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("string"),
      nnkIdentDefs.newTree(
        newIdentNode("x"),
        nnkBracketExpr.newTree(
          newIdentNode("Bar"),
          newIdentNode("auto")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkAsgn.newTree(
        newIdentNode("result"),
        newLit("bar: ")
      ),
      nnkLetSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("maxIdx"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("len"),
            nnkDotExpr.newTree(
              newIdentNode("x"),
              newIdentNode("el")
            )
          )
        )
      ),
      nnkForStmt.newTree(
        newIdentNode("i"),
        nnkInfix.newTree(
          newIdentNode(".."),
          newLit(0),
          nnkInfix.newTree(
            newIdentNode("-"),
            newIdentNode("maxIdx"),
            newLit(1)
          )
        ),
        nnkStmtList.newTree(
          nnkLetSection.newTree(
            nnkIdentDefs.newTree(
              newIdentNode("e"),
              newEmptyNode(),
              nnkBracketExpr.newTree(
                nnkDotExpr.newTree(
                  newIdentNode("x"),
                  newIdentNode("el")
                ),
                newIdentNode("i")
              )
            )
          ),
          nnkCommand.newTree(
            nnkDotExpr.newTree(
              newIdentNode("result"),
              newIdentNode("add")
            ),
            nnkPrefix.newTree(
              newIdentNode("$"),
              nnkPar.newTree(
                newIdentNode("e")
              )
            )
          ),
          nnkIfStmt.newTree(
            nnkElifBranch.newTree(
              nnkInfix.newTree(
                newIdentNode("<"),
                newIdentNode("i"),
                nnkInfix.newTree(
                  newIdentNode("-"),
                  newIdentNode("len"),
                  newLit(1)
                )
              ),
              nnkStmtList.newTree(
                nnkCommand.newTree(
                  nnkDotExpr.newTree(
                    newIdentNode("result"),
                    newIdentNode("add")
                  ),
                  newLit(", ")
                )
              )
            )
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("main"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode()
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("f"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Foo"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("b"),
          newEmptyNode(),
          nnkObjConstr.newTree(
            nnkBracketExpr.newTree(
              newIdentNode("Bar"),
              newIdentNode("float")
            ),
            nnkExprColonExpr.newTree(
              newIdentNode("el"),
              nnkPrefix.newTree(
                newIdentNode("@"),
                nnkBracket.newTree(
                  newLit(25.5)
                )
              )
            )
          )
        )
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("f")
      ),
      nnkCommand.newTree(
        newIdentNode("echo"),
        newIdentNode("b")
      )
    )
  ),
  nnkWhenStmt.newTree(
    nnkElifBranch.newTree(
      newIdentNode("isMainModule"),
      nnkStmtList.newTree(
        nnkCall.newTree(
          newIdentNode("main")
        )
      )
    )
  )
)
Stats
  • GCC 11.4.0
  • Clang 14.0.0
  • NodeJS 20.4
  • Created 2024-08-28T09:01:08Z
  • Comments 1
  • Commands nim cpp --gc:arc -d:nimArcDebug -d:nimArcIds --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 23 mins bisecting 8 commits at 0 commits per second

@beef331
Copy link
Collaborator

beef331 commented Aug 28, 2024

No issue len is not defined, this can be found by explicitly invoking $. Converters are not invoked when they fail. if i < x.el.len-1: makes it work.

@beef331 beef331 closed this as completed Aug 28, 2024
@Clonkk
Copy link
Contributor Author

Clonkk commented Aug 28, 2024

The error message getting lost makes that harder to see

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

No branches or pull requests

2 participants