vlang / v

Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.75k stars 2.16k forks source link

translate multiple declarations result is missing a newline on last #17670

Closed dufresnep closed 1 year ago

dufresnep commented 1 year ago

Describe the bug

[paul@fedora error]$ cat err.c int main() { int n, r, sum = 0, temp; } [paul@fedora error]$ [paul@fedora error]$ v translate err.c C to V translator 0.3.1 translating err.c ... err.v:7:10: error: this number has unsuitable digit t 5 | n := 0 6 | r := 0 7 | sum := 0temp := 0 | ^ 8 |
9 | }

Internal vfmt error while formatting file: err.v. Encountered a total of: 1 errors. took 694 ms ; output .v file: err.v Translated 1 files in 694 ms.

[paul@fedora error]$ cat err.v [translated] module main

fn main() { n := 0 r := 0 sum := 0temp := 0

}

Expected Behavior

[paul@fedora error]$ cat err.v [translated] module main

fn main() { n := 0 r := 0 sum := 0 temp := 0

}

Current Behavior

[paul@fedora error]$ cat err.v [translated] module main

fn main() { n := 0 r := 0 sum := 0temp := 0

}

Reproduction Steps

Idem a describe the bug

Possible Solution

No response

Additional Information/Context

No response

V version

[paul@fedora error]$ v version V 0.3.3 d290f43

Environment details (OS name and version, etc.)

[paul@fedora error]$ v doctor V full version: V 0.3.3 5cb1f89.d290f43 OS: linux, "Fedora release 37 (Thirty Seven)" Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz

getwd: /home/paul/myv/error vexe: /home/paul/v/v vexe mtime: 2023-03-15 17:51:00

vroot: OK, value: /home/paul/v VMODULES: OK, value: /home/paul/.vmodules VTMP: OK, value: /tmp/v_1000

Git version: git version 2.39.2 Git vroot status: weekly.2023.11-7-gd290f432 .git/config present: true

CC version: cc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4) thirdparty/tcc status: thirdparty-linux-amd64 12f392c3 [paul@fedora error]$

dufresnep commented 1 year ago

bug vlang/c2v#115 is probably the same bug, but a less clear example

felipensp commented 1 year ago

PR submitted on c2v repo: https://github.com/vlang/c2v/pull/114