v icon indicating copy to clipboard operation
v copied to clipboard

Compiler crashes with array on toplevel

Open rhysd opened this issue 7 years ago • 6 comments

Repro

Code:

a := [1]
println(a[0])
  1. Save above code as foo.v
  2. Run v foo.v

Expected

Successfully generates binary which prints 1

Actual

v foo.v hangs up

Environment

  • macOS 10.12
  • V ac66d49 or 889d564

EDIT: Confirmed with 889d564

rhysd avatar Jun 23 '19 04:06 rhysd

It still occurs with the latest commit 889d564 for me.

rhysd avatar Jun 23 '19 04:06 rhysd

spams out this when i run it https://i-got.banned.today/4rF5Y3t.png i run linux latest commit, 889d564

superwhiskers avatar Jun 23 '19 04:06 superwhiskers

With optimized build, it just hangs up. But with non-optimized build, it conitnues to dump a lot to stdout.

I took screencast:

demo

rhysd avatar Jun 23 '19 04:06 rhysd

^ verified this just now

superwhiskers avatar Jun 23 '19 04:06 superwhiskers

Verified this. Weird parsing issue:

With following code i get the above issue:

a := [1]
println(a[0])

But if i indent like below:

     a := [1]
     println(a[0])

i get the following parsing error:

a
println

0
pass=1 fn=``
panic: foo.v:2
Fn "println" wrong arg #1. Expected "string" (s)  but got "void"
exit():

also, i thought global state is not supported at all, so without an enclosing function (like main. btw enclosing works as expected), this should always give parser error ?

spy16 avatar Jun 23 '19 05:06 spy16

This works now.

Bowero avatar Jun 26 '19 18:06 Bowero