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

Internal error when using function with static parameter as default argument #21725

Open
SirOlaf opened this issue Apr 24, 2023 · 4 comments
Open

Comments

@SirOlaf
Copy link
Contributor

SirOlaf commented Apr 24, 2023

Description

The code below results in an internal error, the static parameter messes with instantiation

proc test2(value: static[int]): int =
  result = value

proc test1(fn=test2): int =
  fn(1)

discard test1()

Passing test1(test2) is also kinda strange, but at least no internal error

Nim Version

git hash: 897dff6

Current Output

Error: internal error: proc has no result symbol

Expected Output

It should either work or give a better error

Possible Solution

No response

Additional Information

No response

@beef331
Copy link
Collaborator

beef331 commented Apr 24, 2023

Likely should error due to not having a specified generic parameter(remember static parameters are really generics). The following should also error of course.

proc doThing[T] = echo T
proc doOtherThing(fn = doThing) = fn()
doOtherThing()

@juancarlospaco
Copy link
Collaborator

!nim c

func a(v: static[int]): int = v
func b(f=a): int = f(1)
discard b()

@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2023

@juancarlospaco (contributor)

devel :-1: FAIL

Output

Error: Command failed: nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(1, 6) Error: internal error: proc has no result symbol
No stack traceback available
To create a stacktrace, rerun compilation with './koch temp c <file>', see https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler for details

Stats

  • Created 2023-07-05T12:35:59Z
  • Started 2023-07-05T12:36:31
  • Finished 2023-07-05T12:36:31
  • Duration now
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("a"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("v"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("v")
    )
  ),
  nnkFuncDef.newTree(
    newIdentNode("b"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newEmptyNode(),
        newIdentNode("a")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("f"),
        newLit(1)
      )
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      newIdentNode("b")
    )
  )
)
stable :-1: FAIL

Output

Error: Command failed: nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(1, 6) Error: internal error: proc has no result symbol
No stack traceback available
To create a stacktrace, rerun compilation with './koch temp c <file>', see https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler for details

Stats

  • Created 2023-07-05T12:35:59Z
  • Started 2023-07-05T12:36:32
  • Finished 2023-07-05T12:36:32
  • Duration now
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("a"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("v"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("v")
    )
  ),
  nnkFuncDef.newTree(
    newIdentNode("b"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newEmptyNode(),
        newIdentNode("a")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("f"),
        newLit(1)
      )
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      newIdentNode("b")
    )
  )
)
1.6.0 :-1: FAIL

Output

Error: Command failed: nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(1, 6) Error: internal error: proc has no result symbol
No stack traceback available
To create a stacktrace, rerun compilation with './koch temp c <file>', see https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler for details

Stats

  • Created 2023-07-05T12:35:59Z
  • Started 2023-07-05T12:36:35
  • Finished 2023-07-05T12:36:35
  • Duration now
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("a"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("v"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("v")
    )
  ),
  nnkFuncDef.newTree(
    newIdentNode("b"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newEmptyNode(),
        newIdentNode("a")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("f"),
        newLit(1)
      )
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      newIdentNode("b")
    )
  )
)
1.4.0 :-1: FAIL

Output

Error: Command failed: nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(1, 6) Error: internal error: proc has no result symbol
No stack traceback available
To create a stacktrace, rerun compilation with './koch temp c <file>', see https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler for details

Stats

  • Created 2023-07-05T12:35:59Z
  • Started 2023-07-05T12:36:38
  • Finished 2023-07-05T12:36:39
  • Duration now
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("a"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("v"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("v")
    )
  ),
  nnkFuncDef.newTree(
    newIdentNode("b"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newEmptyNode(),
        newIdentNode("a")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("f"),
        newLit(1)
      )
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      newIdentNode("b")
    )
  )
)
1.2.0 :-1: FAIL

Output

Error: Command failed: nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(1, 6) Error: internal error: proc has no result symbol
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp c <file>

Stats

  • Created 2023-07-05T12:35:59Z
  • Started 2023-07-05T12:36:54
  • Finished 2023-07-05T12:36:54
  • Duration now
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("a"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("v"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("v")
    )
  ),
  nnkFuncDef.newTree(
    newIdentNode("b"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newEmptyNode(),
        newIdentNode("a")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("f"),
        newLit(1)
      )
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      newIdentNode("b")
    )
  )
)
1.0.0 :-1: FAIL

Output

Error: Command failed: nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
/home/runner/work/Nim/Nim/temp.nim(1, 6) Error: internal error: proc has no result symbol
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp c <file>

Stats

  • Created 2023-07-05T12:35:59Z
  • Started 2023-07-05T12:37:05
  • Finished 2023-07-05T12:37:06
  • Duration now
  • Commands nim c --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

AST

nnkStmtList.newTree(
  nnkFuncDef.newTree(
    newIdentNode("a"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("v"),
        nnkBracketExpr.newTree(
          newIdentNode("static"),
          newIdentNode("int")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      newIdentNode("v")
    )
  ),
  nnkFuncDef.newTree(
    newIdentNode("b"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newIdentNode("int"),
      nnkIdentDefs.newTree(
        newIdentNode("f"),
        newEmptyNode(),
        newIdentNode("a")
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkCall.newTree(
        newIdentNode("f"),
        newLit(1)
      )
    )
  ),
  nnkDiscardStmt.newTree(
    nnkCall.newTree(
      newIdentNode("b")
    )
  )
)
🤖 Bug found in 38 minutes bisecting 6 commits at 0 commits per second.

@metagn
Copy link
Collaborator

metagn commented Sep 16, 2023

Probably related #16906

Passing test1(test2) is also kinda strange

Should error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants