Skip to content

can't parse some asm constraint in inline assembly #25070

Description

@kbkpbot

Describe the bug

The V parser does not support some asm constraint in inline assembly.
for example :

                ; =&r (lo)
                  =&r (hi)

Reproduction Steps

t.v

module main

fn mul_64(x u64, y u64) (u64, u64) {
        mut hi := u64(0)
        mut lo := u64(0)
        asm amd64 {
                mov rax, x
                mulq y
                mov lo, rax
                mov hi, rdx
                ; =&r (lo)
                  =&r (hi)
                ; r (x)
                  r (y)
                ; rax
                  rdx
                  cc
        }
        return hi, lo
}

fn main() {
        i, j := mul_64(100, 200)

        println(i)
        println(j)
}

Expected Behavior

compile OK

Current Behavior

$ $ v t.v
t.v:11:6: error: unexpected token `&`, expecting name
    9 |         mov lo, rax
   10 |         mov hi, rdx
   11 |         ; =&r (lo)
      |            ^
   12 |           =&r (hi)
   13 |         ; r (x)

Possible Solution

Fix parser

Additional Information/Context

No response

V version

V 0.4.11 3b561d5.0dcd3b1

Environment details (OS name and version, etc.)

V full version V 0.4.11 3b561d5.0dcd3b1
OS linux, Ubuntu 24.04.3 LTS
Processor 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
Memory 8.2GB/15.51GB
V executable /media/HD/github/kbkpbot/v/v
V last modified time 2025-08-08 14:10:09
V home dir OK, value: /media/HD/github/kbkpbot/v
VMODULES OK, value: /home/mars/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/mars/v/bug/asm
Git version git version 2.43.0
V git status weekly.2025.17-534-g0dcd3b11-dirty
.git/config present true
cc version cc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
gcc version gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
clang version Ubuntu clang version 18.1.3 (1ubuntu1)
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (Ubuntu GLIBC 2.39-0ubuntu8.5) 2.39

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

Labels

BugThis tag is applied to issues which reports bugs.Unit: ParserBugs/feature requests, that are related to the V parser or syntax (*not* semantic ones).

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions