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 - `t.destructor != nil` [AssertionError] with `toTable()` #11014

Closed
nc-x opened this Issue Apr 12, 2019 · 5 comments

Comments

Projects
None yet
6 participants
@nc-x
Copy link
Contributor

nc-x commented Apr 12, 2019

import tables

var x = {
    1: 1
}.toTable()

echo x

nim c --newruntime t.nim

..\lib\system\fatal.nim(37) sysFatal
Error: unhandled exception: C:\Nim\compiler\liftdestructors.nim(329, 14) `t.destructor != nil`  [AssertionError]
@cooldome

This comment has been minimized.

Copy link
Member

cooldome commented Apr 12, 2019

tried with very latest dev nim. Seems to work fine with today's fixes by Araq.
Please keep on testing newruntime very useful.

@nc-x

This comment has been minimized.

Copy link
Contributor Author

nc-x commented Apr 13, 2019

@cooldome
I still get the crash on latest devel (git hash: e33266ded1ad31cfd0776e6ec8d1a2c399994068)

@cooldome

This comment has been minimized.

Copy link
Member

cooldome commented Apr 13, 2019

hmmm true, issue still happes in fdc3f54
my apologies

@zevv

This comment has been minimized.

Copy link
Contributor

zevv commented Apr 15, 2019

Also reproduces with:

var e = initTable[char, bool]()
e['a'] = true
@Clyybber

This comment has been minimized.

Copy link
Contributor

Clyybber commented Apr 15, 2019

I extracted this minimal repro snippet from the tables module:

type
  KeyValuePairSeq[T] = seq[int]
  Table*[T] = object
    data: KeyValuePairSeq[T]

proc initTable*[T](): Table[T] =
  discard

proc enlarge() =
  var n: KeyValuePairSeq[int] #Replace this with discard and it works again

var e = initTable[char]() #Remove this and it works again (doesn't matter if var e or let e)
enlarge() #Also fails without calling enlarge

Whats interesting is, that upon removing the var e = ... line it compiles just fine, even though enlarge doesn't touch e at all ?!

And even more crazy:
Removing the call to enlarge at the end doesn't change anything, it still fails.
...
However; if you replace the body of enlarge with discard it compiles fine again, no matter if you call it or not.

Removing any of the generic parameters also makes this compile again.

@mratsim mratsim added the Generics label Apr 15, 2019

Clyybber added a commit to Clyybber/Nim that referenced this issue Apr 15, 2019

Clyybber added a commit to Clyybber/Nim that referenced this issue Apr 15, 2019

@Araq Araq closed this in d8a8c88 Apr 16, 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.