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

var a: FooNotNil should give CT error, breaks not nil semantics, causing SIGSEGV #13827

Open
timotheecour opened this issue Mar 31, 2020 · 2 comments

Comments

@timotheecour
Copy link
Member

var a: FooNotNil should give CT error, breaks not nil semantics, causing SIGSEGV

Example

when true:
  type Foo = ref object
    x: int
  type Foo2 = Foo not nil
  proc main2(a: Foo2) =
    echo a.x
  block:
    var x: Foo2 # BUG: should give CT error
    main2(x) # SIGSEGV
  block:
    var x = default(Foo2)  # BUG: should give CT error
    main2(x)  # SIGSEGV

Current Output

SIGSEGV: Illegal storage access

Expected Output

CT error for both var x: Foo2 and var x = default(Foo2)

Additional Information

@zah
Copy link
Member

zah commented Apr 1, 2020

#13808 detects these situations. The original version of the PR was producing errors for them, but Araq and I agreed to settle for warnings for now. This would give the community more time to decide how to deal with some of the trickier issues such as seq.setLen being unsafe for not nil types as well.

@timotheecour
Copy link
Member Author

some of the trickier issues such as seq.setLen being unsafe for not nil types as well.

I've suggested ignoreNotNil here: #13808 (comment) for that and all such cases

@ghost ghost added the `not nil` Checking label Jul 26, 2020
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

2 participants