v icon indicating copy to clipboard operation
v copied to clipboard

String interpolation should work inside attributes

Open Apocryphon-X opened this issue 3 years ago • 0 comments

V Doctor:

OS: linux, Ubuntu 20.04.4 LTS (WSL 2)
Processor: 12 cpus, 64bit, little endian, 11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz
CC version: cc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

getwd: /home/apocryphon/tests/v
vmodules: /home/apocryphon/.vmodules
vroot: /home/apocryphon/packages/v
vexe: /home/apocryphon/packages/v/v
vexe mtime: 2022-07-24 17:00:00
is vroot writable: true
is vmodules writable: true
V full version: V 0.3.0 d6de533.297cb5f

Git version: git version 2.25.1
Git vroot status: weekly.2022.29-57-g297cb5f8
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 827f7452

What did you do?

struct Dummy {}

const sample_text = 'Lorem Ipsum'

[foo: '$sample_text']
fn (d Dummy) sample_method() {
	// ...
}

fn main() {
	$for methods in Dummy.methods {
		println(methods)
	}
}

What did you expect to see?

FunctionData{
    name: 'sample_method'
    attrs: ['foo: Lorem Ipsum']
    args: []
    return_type: 1
    typ: 0
}

What did you see instead?

bug_4.v:5:8: error: unexpected token `$2`, expecting `;`
    3 | const sample_text = 'Lorem Ipsum'
    4 | 
    5 | [foo: '$sample_text']
      |        ^
    6 | fn (d Dummy) sample_method() {
    7 |     // ...

Apocryphon-X avatar Jul 25 '22 01:07 Apocryphon-X