Skip to content

var T return value can be uninitialized #1552

@alaviss

Description

@alaviss

Example

type Foo* = object
  s: string

func leak*(A: var Foo): var Foo = discard

proc main() =
  var a: Foo
  echo a.leak().s

main()

Actual Output

Traceback (most recent call last)
test.nim(10)        test
test.nim(8)         main
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Expected Output

An uninitialized view should be a compile-time error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompiler/semRelated to semantic-analysis system of the compiler

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions