V: String interpolation Broken Again? - When Not Wrapped in fn main()

Created on 17 Feb 2020  路  2Comments  路  Source: vlang/v

As per closed issue #741

I'm seeing this again with V 0.1.25 a2838ae

import os

//fn main()
//{
// some vars
homepath := os.getenv("HOME")
configpath := "$homepath/.ssb/scutty.cfg"
println(configpath)
//}

```
v run tester.v
tester.v:7:41: cannot interpolate this value
5| // some vars
6| homepath := os.getenv("HOME")
7| configpath := "$homepath/.ssb/scutty.cfg"
^
8| println(configpath)
9| //}

Wrap it in a main function and it works again:

```V
import os

fn main()
{
// some vars
homepath := os.getenv("HOME")
configpath := "$homepath/.ssb/scutty.cfg"
println(configpath)
}
v run tester.v
/Users/madra/.ssb/scutty.cfg
Bug

Most helpful comment

Yes it's the notorious no fn main bug

It'll be fixed for good in the new parser this month.

All 2 comments

Yes it's the notorious no fn main bug

It'll be fixed for good in the new parser this month.

Works fine on the latest V.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jtkirkpatrick picture jtkirkpatrick  路  3Comments

cjmxp picture cjmxp  路  3Comments

markgraydev picture markgraydev  路  3Comments

choleraehyq picture choleraehyq  路  3Comments

medvednikov picture medvednikov  路  3Comments