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

view outlive the location it was borrowed from #19985

Open
gabbhack opened this issue Jul 7, 2022 · 0 comments
Open

view outlive the location it was borrowed from #19985

gabbhack opened this issue Jul 7, 2022 · 0 comments

Comments

@gabbhack
Copy link

gabbhack commented Jul 7, 2022

Example

{.experimental: "views".}

type
  Foo = object
    value: openArray[string]

proc main(): auto =
  let a = ["1", "2", "3"]

  let foo = Foo(value: a.toOpenArray(0, 2))
  
  return foo

echo main()

https://play.nim-lang.org/#ix=41Mo

Current Output

SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault (core dumped)

Expected Output

Compile-time error

$ nim -v
Nim Compiler Version 1.6.6 [Windows: amd64]
Compiled at 2022-05-05
Copyright (c) 2006-2021 by Andreas Rumpf

active boot switches: -d:release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant