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

Compiler crashes on ptr void #6456

Closed
obadz opened this issue Sep 30, 2017 · 4 comments
Closed

Compiler crashes on ptr void #6456

obadz opened this issue Sep 30, 2017 · 4 comments

Comments

@obadz
Copy link

obadz commented Sep 30, 2017

The Nim compiler seems to crash when objects have a ptr void member and neither give an explicit error message nor a line number. For example:

type
    a* = object
        b*: int
        c*: ptr void  
    
proc main() =
    var x = a(b: 4)
    echo $x.b

main()    

Yields:

Error: internal error: getTypeDescAux(tyVoid)
Traceback from system (most recent call last)

(No tracebacks provided)

Tested with nim version 0.17.0.

@ghost
Copy link

ghost commented Sep 30, 2017

@obadz yeah, it shouldn't crash, but you can't do "ptr void"
use "pointer" instead

type
    a* = object
      b*: int
      c*: pointer 
    
proc main() =
    var x = a(b: 4)
    let a = "hello"
    x.c = cast[pointer](a)
    echo cast[int64](x.c)  # Pointer as int :)
    echo cast[string](x.c)

main()

You can use any types you want here (well, if they're references)

@obadz
Copy link
Author

obadz commented Sep 30, 2017

@Yardanico,

It took me a while to realize this was even causing the error because of the lack of error message / line number.

Also I didn't put this ptr void there, c2nim did.

I replaced by pointer.

@zah
Copy link
Member

zah commented Jun 27, 2018

Fixed in #8127

@zah zah closed this as completed Jun 27, 2018
@shirleyquirk
Copy link
Contributor

same crash on

import sharedlist
var s:SharedList[void]
s.init()

obvs low priority, just sayin.

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

3 participants