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

newruntime and unused generics: compiler crash #6755

Closed
mratsim opened this issue Nov 15, 2017 · 4 comments

Comments

Projects
None yet
4 participants
@mratsim
Copy link
Collaborator

commented Nov 15, 2017

Compile this with nim c --newruntime --d:newruntime

type CustSeq = object
  data: seq[int]


proc newCustSeq(len: Natural): CustSeq =
  result.data = newSeq[int](len)

when defined(newruntime):
  echo "Using Nim new runtime"

  proc `=sink`[T](a: var CustSeq, b: CustSeq) =
    echo "Value sinked"
    shallowCopy(a, b)

  proc `=move`[T](a, b: var CustSeq) =
    echo "Value moved"
    shallowCopy(a, b)


proc main() =
  let a = newCustSeq(10)
  let b = a
  echo b

main()
Error: internal error: (filename: ccgexprs.nim, line: 972)
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp c <file>

Removing the [T] to the sink and move solves the issue

@Yardanico

This comment has been minimized.

Copy link
Collaborator

commented Dec 13, 2017

Gives better error now:

Hint: used config file '/home/yardanico/Nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: test [Processing]
injecting into
## generic ``$`` operator for tuples that is lifted from the components
## of `x`. Example:
##
## .. code-block:: nim
##   $(23, 45) == "(23, 45)"
##   $() == "()"
result = "("
var firstElement = true
if not firstElement: add(result, ", ")
add(result, "data")
add(result, ": ")
if isNil(x.data): add(result, "nil")
else: add(result, $x.data)
firstElement = false
add(result, ")")
injecting into
let a = newCustSeq(10)
let b = a
echo [b]
test.nim(21, 7) Error: internal error: '=sink' operator is generic
@Yardanico

This comment has been minimized.

Copy link
Collaborator

commented Feb 15, 2018

@mratsim now prints:

tata.nim(21, 7) Error: internal error: '=sink' operator is generic
@narimiran

This comment has been minimized.

Copy link
Member

commented Apr 11, 2019

Gives better error now:

Gives worse error now:

SIGSEGV: Illegal storage access. (Attempt to read from nil?)

@narimiran

This comment has been minimized.

Copy link
Member

commented Apr 18, 2019

Gives worse error now:

...and better once again:

Error: unhandled exception: ..../compiler/liftdestructors.nim(583, 12) `typ.typeInst != nil` [AssertionError]

@Araq Araq closed this in 950f2d7 May 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.