nim-works / nimskull

An in development statically typed systems programming language; with sustainability at its core. We, the community of users, maintain it.
https://nim-works.github.io/nimskull/index.html
Other
271 stars 38 forks source link

Compiler crash with ambiguous function call #1405

Open starsiderfox opened 1 month ago

starsiderfox commented 1 month ago

Specification

The compiler crashes when a proc is called with a parameter of ambiguous type.

Example

proc f(x: seq[int]|seq[float]) = discard
f @[]

Actual Output

nim.nim                  nim
nim.nim                  handleCmdLine
main.nim                 mainCommand
main.nim                 compileToBackend
main.nim                 commandCompileToC
cbackend.nim             generateCode
cbackend.nim             generateCode
backends.nim             translate
mirgen.nim               generateCode
mirgen.nim               gen
mirgen.nim               gen
mirgen.nim               genCallOrMagic
mirgen.nim               genCall
mirgen.nim               genArgs
mirgen.nim               genArg
mirgen.nim               emitOperandTree
mirgen.nim               genArgExpression
mirgen.nim               genx
mirgen.nim               typeToMir
mirtypes.nim             add
mirtypes.nim             handleImported
mirtypes.nim             typeSymToMir
mirtypes.nim             typeToMir
mirtypes.nim             add
mirtypes.nim             handleImported
mirtypes.nim             typeSymToMir
mirtypes.nim             typeToMir
idioms.nim               unreachableImpl
idioms.nim               unreachableImpl
assertions.nim           raiseAssert
fatal.nim                sysFatal
Error: unhandled exception: mirtypes.nim(885, 16) unreachable: tyEmpty [AssertionDefect]

Expected Output

Maybe some error message that at least explains where the problem occurs. Although personally I would prefer that the first compatible type is selected automatically.

Additional Information

nim_dbg doesn't show any location data.

saem commented 1 month ago

Maybe some error message that at least explains where the problem occurs. Although personally I would prefer that the first compatible type is selected automatically.

If it's ambiguous then it has to be an error, silently succeeding is far worse.