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

String interpolation in raw string may be broken #2631

Closed
lenaing opened this issue Nov 3, 2019 · 5 comments
Closed

String interpolation in raw string may be broken #2631

lenaing opened this issue Nov 3, 2019 · 5 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@lenaing
Copy link
Contributor

lenaing commented Nov 3, 2019

Hello !

V version: V 0.1.22 3449a8b
OS : Linux 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) x86_64 GNU/Linux

What did you do ?
I tried to use a variable in raw string with interpolation.
I'm not sure if it should break or not. I believe that it should work as normal string interpolation ?

fn main() {
    hello := 'world'
    println('hello\n$hello')
    println(r'hello\n$hello')
}

What did you expect to see?

$ v run test.v
hello
world
hello\nworld

What did you see instead?

$ v run test.v 
check()
next token = `hello`
addr2line: 'v': No such file
v(+0x3a12b) [0x55aa0d33512b]
addr2line: 'v': No such file
v(+0x2216b) [0x55aa0d31d16b]
addr2line: 'v': No such file
v(+0x1f627) [0x55aa0d31a627]
addr2line: 'v': No such file
v(+0x3f813) [0x55aa0d33a813]
addr2line: 'v': No such file
v(+0x44b04) [0x55aa0d33fb04]
addr2line: 'v': No such file
v(+0x4454c) [0x55aa0d33f54c]
addr2line: 'v': No such file
v(+0x44271) [0x55aa0d33f271]
addr2line: 'v': No such file
v(+0x43467) [0x55aa0d33e467]
addr2line: 'v': No such file
v(+0x4375b) [0x55aa0d33e75b]
addr2line: 'v': No such file
v(+0x3df71) [0x55aa0d338f71]
addr2line: 'v': No such file
v(+0x3dcdf) [0x55aa0d338cdf]
addr2line: 'v': No such file
v(+0x3bc2b) [0x55aa0d336c2b]
addr2line: 'v': No such file
v(+0x3b33b) [0x55aa0d33633b]
addr2line: 'v': No such file
v(+0x1deac) [0x55aa0d318eac]
addr2line: 'v': No such file
v(+0x382af) [0x55aa0d3332af]
addr2line: 'v': No such file
v(+0x2c385) [0x55aa0d327385]
addr2line: 'v': No such file
v(+0x2c939) [0x55aa0d327939]
addr2line: 'v': No such file
v(+0x60952) [0x55aa0d35b952]
addr2line: 'v': No such file
v(+0x61f12) [0x55aa0d35cf12]
??:0:                                         | /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb) [0x7f592895f09b]
addr2line: 'v': No such file
v(+0x249a) [0x55aa0d2fd49a]
test.v:4:27: expected `)` but got `$`
    2|     hello := 'world'
    3|     println('hello\n$hello')
    4|     println(r'hello\n$hello')
                                 ^
    5| }
@lenaing lenaing added the Bug This tag is applied to issues which reports bugs. label Nov 3, 2019
@medvednikov
Copy link
Member

Fixed.

@lenaing
Copy link
Contributor Author

lenaing commented Nov 3, 2019

Well, now it does not fails on the '$', but var is still not interpolated, shouldn't it ?

$ v run test.v
hello
world
hello\n$hello

@medvednikov
Copy link
Member

No, it's a raw string, no interpolation here.

@medvednikov
Copy link
Member

medvednikov commented Nov 3, 2019

Looks like in Python they can be combined with rf'foo': https://www.python.org/dev/peps/pep-0498/#raw-f-strings

$@"foo" in C#.

I want to keep things simple.

@bitcartel
Copy link

I can confirm using V 0.1.22 a6a233d the issue is resolved i.e. no interpolation when using raw string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

4 participants