-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Labels
BugThis tag is applied to issues which reports bugs.This tag is applied to issues which reports bugs.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.This bug has been confirmed to be valid by a contributor.Unit: cgenBugs/feature requests, that are related to the default C generating backend.Bugs/feature requests, that are related to the default C generating backend.Unit: markusedBugs/feature requests, that are related to the -skip-unused.Bugs/feature requests, that are related to the -skip-unused.
Description
Describe the bug
After upating v from 0.4.9
to 0.4.10
this (stripped down) server.v
code doesn't compile anymore:
import veb
import x.json2
pub struct Context {
veb.Context
}
pub struct App {
veb.Middleware[Context]
}
@['/'; POST]
fn (app &App) index(mut ctx Context) veb.Result {
j := json2.raw_decode(ctx.req.data) or {
return ctx.request_error("error")
}
m := j.as_map()
myarr := m['myarr'] or { panic(error) }
m2 := myarr.arr()
for mc in m2 {
parts := mc.arr()
// Compiler error occurs here -->
first := parts[0].str()
second := parts[1].str()
third := parts[2].str()
println("1. ${first}, 2. ${second}, 3. ${third}")
}
return ctx.ok("ok")
}
fn main(){
mut app := &App{}
veb.run[App, Context](mut app, 3000)
}
Reproduction Steps
Simply try to compile v server.v
Expected Behavior
No compiling issues.
Current Behavior
% v server.v
================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/server.01JT9M27J0TC65V48EZBS0WVS1.tmp.c:16742: warning: implicit declaration of function 'time__Time_local_to_utc'
cc: /tmp/v_1000/server.01JT9M27J0TC65V48EZBS0WVS1.tmp.c:16742: error: '{' expected (got ";")
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error:
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .
Possible Solution
No response
Additional Information/Context
Interestingly, this code snippet works as it also uses json2.raw_decode:
import x.json2
fn main() {
j := json2.raw_decode('{"myarr" : [["first", "second", "third"]]}') or {
panic(err)
}
m := j.as_map()
myarr := m['myarr'] or { panic(error) }
m2 := myarr.arr()
for mc in m2 {
parts := mc.arr()
first := parts[0].str()
second := parts[1].str()
third := parts[2].str()
println("1. ${first}, 2. ${second}, 3. ${third}")
}
}
V version
0.4.10 875c165
Environment details (OS name and version, etc.)
V full version | V 0.4.10 9ae8cc3.875c165 |
---|---|
OS | linux, Linux Mint 22.1 |
Processor | 6 cpus, 64bit, little endian, Intel(R) Core(TM) i5-9500T CPU @ 2.20GHz |
Memory | 16.58GB/62.15GB |
V executable | /home/flex/v/v |
V last modified time | 2025-05-02 21:26:10 |
V home dir | OK, value: /home/flex/v |
VMODULES | OK, value: /home/flex/.vmodules |
VTMP | OK, value: /tmp/v_1000 |
Current working dir | OK, value: /tmp/v_bug |
Git version | git version 2.43.0 |
V git status | weekly.2025.12-217-g875c1654 |
.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 2024-07-31 HEAD@1cee0908 (x86_64 Linux) |
tcc git status | thirdparty-linux-amd64 0134e9b9 |
emcc version | N/A |
glibc version | ldd (Ubuntu GLIBC 2.39-0ubuntu8.4) 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.This tag is applied to issues which reports bugs.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.This bug has been confirmed to be valid by a contributor.Unit: cgenBugs/feature requests, that are related to the default C generating backend.Bugs/feature requests, that are related to the default C generating backend.Unit: markusedBugs/feature requests, that are related to the -skip-unused.Bugs/feature requests, that are related to the -skip-unused.