1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

Compare commits

...

3156 Commits

Author SHA1 Message Date
Delyan Angelov
692624b47c parser: add error for typeof(T), suggesting typeof[T]() instead 2023-06-06 11:27:17 +03:00
Felipe Pena
d3c679bdcb cgen: fix fixed array of map (#18347) 2023-06-05 16:46:48 +03:00
yuyi
254ed1766c ast: minor cleanup in generic_insts_to_concrete() (#18349) 2023-06-05 16:46:23 +03:00
Felipe Pena
169627722a cgen: circular reference limit to auto_str for interface (#18340) 2023-06-05 16:45:44 +03:00
Swastik Baranwal
48c256bf3b checker: allow casted enum val and const as fixed array size (#18321) 2023-06-05 16:44:55 +03:00
Felipe Pena
5440657364 fmt: fix alias type stripped comments (#18346) 2023-06-05 01:53:17 +02:00
yuyi
325f64bc60 ast: fix for in iterator with generic structs (#18344) 2023-06-04 18:15:15 +02:00
Ulises Jeremias Cornejo Fandos
02ea6028af vlib: improvements to the context module (#18318) 2023-06-04 18:12:52 +02:00
yuyi
0e106c9062 checker: fix generic fn infering map argument (#18341) 2023-06-04 18:10:41 +02:00
Felipe Pena
8d2a0ffe37 cgen: fix option handling with auto heap variable (#18336) 2023-06-04 18:10:22 +02:00
Alexander Medvednikov
9dcd95ee34 examples: use printf in the coroutines example for now 2023-06-03 23:56:07 +02:00
Alexander Medvednikov
6fe6fe887d coroutines: $if is_coroutine? { 2023-06-03 19:05:50 +02:00
Felipe Pena
4e21b2ab4e parser: detect wrong usage of Option as concrete type (#18334) 2023-06-03 13:24:25 +02:00
kbkpbot
0fc33c6fa3 datatypes: add Bloom filter (#18327) 2023-06-02 10:56:22 +03:00
Lenni0451
9764342dbe vweb: add support for host specific static files (#18322) 2023-06-02 10:55:59 +03:00
Felipe Pena
a8ea1f9d50 cgen, checker, parser: fix fixed array with channel (#18315) 2023-06-02 10:55:08 +03:00
Felipe Pena
82035f7610 repl: fix comparison operator treated as statement (#18304) 2023-06-02 10:54:43 +03:00
yuyi
5e12d3483c checker: fix generic fn with nested generic fn call (fix #18285) (#18314) 2023-06-02 10:52:29 +03:00
Alexander Medvednikov
a647a71c52 roadmap: remove any 2023-05-30 18:39:37 +02:00
yuyi
4dc338863c checker: fix json decode with generic array of struct (fix #18300) (#18308) 2023-05-30 14:25:33 +02:00
yuyi
ac6289301c ast, cgen: fix generic struct with inconsistent generic types (fix #18254) (#18301) 2023-05-30 14:24:54 +02:00
Turiiya
af05cfcbbc toml, semver: minor optimization of conditions (#18299) 2023-05-30 14:24:27 +02:00
Felipe Pena
0b71cef78a cgen: fix generic comptimeselector array resolution (#18296) 2023-05-30 14:23:37 +02:00
Turiiya
e9fb5b3fcc .editorconfig: do not specify an indent size for tabs (#18297) 2023-05-30 14:23:13 +02:00
Felipe Pena
f430c0b67a parser: fix for select parsing (#18306) 2023-05-30 14:22:47 +02:00
Casper Kuethe
4174048f96 vweb: add host option to controller (#18303) 2023-05-30 14:22:23 +02:00
Felipe Pena
05b832a317 cgen: fix none initialization to struct member (#18295) 2023-05-29 15:35:41 +03:00
Delyan Angelov
ae8e9af11f ci: skip building examples/coroutines/simple_coroutines.v for now 2023-05-29 13:35:46 +03:00
Delyan Angelov
d47c722c1f builtin: fix byte deprecation warnings for v test-all (the -freestanding compilation) 2023-05-29 13:20:29 +03:00
Lenni0451
2904c399b5 vweb: host attribute (#18288) 2023-05-29 02:11:10 +02:00
Alexander Medvednikov
f22ba836fd prealloc: use u8 instead of byte 2023-05-29 01:42:52 +02:00
Alexander Medvednikov
3f62487409 examples: add a simple coroutine example 2023-05-29 01:35:38 +02:00
Turiiya
1be539d20f checker: add byte deprecation warning (#18287) 2023-05-28 23:30:32 +02:00
Alexander Medvednikov
3ac63cce86 fmt: fix a shared test 2023-05-28 18:23:07 +03:00
Alexander Medvednikov
f8422738bb vfmt: no longer replace go with spawn 2023-05-28 16:03:39 +02:00
Alexander Medvednikov
786865d349 coroutines: init() that runs automatically 2023-05-28 15:54:57 +02:00
Turiiya
80d404c220 checker: replace as cast with a safer type check is (smart cast) (#18286) 2023-05-28 05:41:46 +02:00
Alexander Medvednikov
9db10c8f61 all: coroutines (part 2) 2023-05-28 05:30:23 +02:00
Alexander Medvednikov
2162230086 cgen: move spawn and go logic to a separate file 2023-05-28 02:52:38 +02:00
Alexander Medvednikov
50247d5093 gen.golang: handle spawn/go 2023-05-28 02:44:47 +02:00
Alexander Medvednikov
45f16a2640 all: coroutines (part 1) 2023-05-27 23:33:46 +02:00
Felipe Pena
5812579d53 checker: remove check for option being initialized (#18280) 2023-05-27 20:43:54 +02:00
Felipe Pena
16ef1d95fb cgen: fix fixed array ret with anon fn (#18279) 2023-05-27 20:42:31 +02:00
Felipe Pena
6bfa6ec93c cgen: fix comptime interpolation (#18281) 2023-05-27 20:41:40 +02:00
xiusin
43bc85d3bb http: add workers to improve the server's concurrent capacity. (#18271) 2023-05-27 01:57:32 +03:00
Turiiya
f9efbdff10 semver: refactor, simplify, fix typo (#18272) 2023-05-27 01:57:02 +03:00
Turiiya
3e08487198 checker: disallow multiple return values in const declarations (#18273) 2023-05-27 01:55:14 +03:00
yuyi
6db62e43d3 parser: fix array method using it in defer (fix #18246) (#18267) 2023-05-26 02:29:52 +02:00
Casper Kuethe
79657a1a2f vweb: update middleware docs (#18270) 2023-05-26 02:26:00 +02:00
Mark aka walkingdevel
b698a0f459 mysql: add the ability to commit transactions, some code improvements (#18268) 2023-05-26 02:16:02 +02:00
Felipe Pena
8a856cc36d checker: adjust fix for struct anon assigning to typed struct (#18264) 2023-05-25 20:40:20 +03:00
Felipe Pena
e8289dd4d5 changelog: add entry about heap usage api (#18265) 2023-05-25 17:27:49 +02:00
Mark aka walkingdevel
c2fa45c24d cgen, orm: fix typo, and wrap the fkey attribute into quotes in errors (#18266) 2023-05-25 17:27:25 +02:00
Turiiya
993546a0a2 examples: fix typos (#18229) 2023-05-25 16:54:46 +03:00
yuyi
caee3935a5 os: fix truncate() on windows (#18262) 2023-05-25 14:37:53 +03:00
Felipe Pena
bc88183318 cgen: fix struct fn ptr call (#18260) 2023-05-25 10:52:05 +03:00
Felipe Pena
dc16e50d55 regex: fix find() when using anchors (start / end) (#18259) 2023-05-25 10:51:41 +03:00
Felipe Pena
fc6a34355d parser: fix missing sync auto import when only declaring shared type and not using it (#18255) 2023-05-25 02:54:04 +02:00
Felipe Pena
9d56432e55 checker: add missing check for mismatch anon struct to typed struct (#18250) 2023-05-25 02:53:14 +02:00
Felipe Pena
64a4a3316a checker, cgen: fix fixed array return on assigning, arg pass and dumping (#18216) 2023-05-25 02:52:45 +02:00
yuyi
f1c647cbbe parser: make most of parser methods private (#18249) 2023-05-25 02:51:59 +02:00
yuyi
190f5c69ea os: fix open_file() on windows (fix #18245) (#18253) 2023-05-25 02:50:52 +02:00
Mark aka walkingdevel
351b2e0e42 mysql: refactor, comments, simplify (#18258) 2023-05-25 02:50:15 +02:00
xy3
010a5c26a0 vpm: increment vpm downloads, use new endpoints (#18202) 2023-05-25 02:47:58 +02:00
Alexander Medvednikov
c45c36ccce orm: improve an fkey error a bit 2023-05-24 18:30:44 +02:00
Felipe Pena
e8dbd2c0c7 parser: fix enum attr with default value (#18248) 2023-05-24 17:25:27 +03:00
yuyi
099d4fc06f parser: clean up in parser.v (#18247) 2023-05-24 06:51:15 +03:00
Turiiya
e8046439f0 cgen: include float kind in struct field type defaults (#18228) 2023-05-24 06:50:45 +03:00
Felipe Pena
598673314b json.decode: add check for shared variable (#18237) 2023-05-24 06:47:09 +03:00
yuyi
6698fe4f60 checker, cgen: fix contains() with array of interfaces (#18241) 2023-05-23 14:46:14 +02:00
Felipe Pena
37618c9465 cgen, checker: fix comptime assigning to sumtype or indexexpr (#18240) 2023-05-23 14:42:53 +02:00
yuyi
e2f18fc9cc checker, cgen: fix array of interfaces index() (#18232) 2023-05-22 16:31:22 +03:00
Alexander Medvednikov
a33ffcedfb parser: remove attributes from anonymous structs (fixes #18233) 2023-05-22 14:13:34 +02:00
Delyan Angelov
c382f4d310 rand: add missing rand.u16(), update doc comments, add test 2023-05-22 13:20:52 +03:00
Alexander Medvednikov
3a09142ace doc: update memory management info 2023-05-22 08:36:38 +02:00
Turiiya
1be798be49 net.html: remove unnecessary comment (#18230) 2023-05-22 07:46:26 +03:00
kbkpbot
a10690b934 net.conv: use a pure v implementation instead of C.hton etc (#18226) 2023-05-22 06:59:33 +03:00
Mark aka walkingdevel
ce0591da8d mysql: allocate memory for each string and blob dynamically depending on its value length (#18214) 2023-05-21 15:24:43 +02:00
sandbankdisperser
f833188234 vweb: return 404 on file not found (#18219) 2023-05-21 15:23:43 +02:00
xiusin
e4c769d072 net.http: add remote-addr header (#18208) 2023-05-21 15:23:24 +02:00
Felipe Pena
38a155ac81 cgen: make comptime call works with or-block (#18215) 2023-05-21 15:22:40 +02:00
Akhil Binoy
30e02cfa3d examples: fix typo in bellman-ford.v (#18223) 2023-05-21 15:22:27 +02:00
Swastik Baranwal
4b22ea7803 parser: disallow all array usage outside of builtin (#18222) 2023-05-21 15:21:57 +02:00
Ikko Eltociear Ashimine
abcbba1e81 builtin: fix typo in string.js.v (#18213) 2023-05-21 02:46:11 +03:00
Casper Kuethe
d0214a254e vweb: vweb.csrf re-implementation (#18220) 2023-05-21 01:56:17 +03:00
yuyi
adcf47dcce checker: appending to an array of sumtype (#18201) 2023-05-20 02:25:26 +03:00
Mark aka walkingdevel
1e9dcb9b9e checker: refactor, comments, simplify. (#18203) 2023-05-20 02:24:30 +03:00
yuyi
94217571cd parser, checker, cgen: fix swapping arrays (#18204) 2023-05-20 02:23:50 +03:00
yuyi
332235548e checker: clean up in array_init() (#18205) 2023-05-20 02:21:52 +03:00
Petr Makhnev
9d0a1d8496 builtin: speed up string methods with vmemcpy instead of for loop for copying data (#18211) 2023-05-19 21:24:23 +03:00
Turiiya
aded6088e9 vet: allow vetting files with global variables (#18195) 2023-05-19 16:28:01 +03:00
Petr Makhnev
a39c26507c builtin: speed up string concatenation and repeat() method with vmemcpy instead of for loop for copying data (#18206)
These changes almost do not speed up the program with the `-prod` flag,
since modern С compilers can do such optimization on their own, but in
normal mode, the performance gain is from 1.6 (concatenation) to 1.8 (repeat) times.

Concatenation:
Old (`for` loop):
Time (mean):          3.699 s +- 0.071 s  [User: 3.629 s, System: 0.069 s]
Range (min ... max):  3.548 s ... 3.741 s  10 runs

New (vmemcpy):
Time (mean):          2.305 s +- 0.065 s  [User: 2.263 s, System: 0.041 s]
Range (min ... max):  2.172 s ... 2.355 s  10 runs

`vmemcpy version` ran 1.60 +- 0.05 times faster than 'for loop version'
2023-05-19 16:18:23 +03:00
Alexander Medvednikov
f67952fe84 doc: use u8 instead of byte 2023-05-18 12:24:00 +02:00
Alexander Medvednikov
cc47c78f39 net.mbedtls: make compile with -prod 2023-05-18 11:31:53 +02:00
Felipe Pena
9d9785cc05 all: allow fixed array returns (#17931) 2023-05-18 11:30:49 +02:00
kbkpbot
c8d2098a14 net.websocket: make thread safe/concurrent (#18179) 2023-05-18 11:27:00 +02:00
Felipe Pena
1e88b1ab3e cgen: fix missing panic message for 'option not set' on debug (#18168) 2023-05-18 11:25:19 +02:00
Felipe Pena
273f46f810 checker: fix generic argument resolution when mixed order on next call (#18192) 2023-05-18 11:24:06 +02:00
Leon Arndt
2c95b9be32 examples: removed unused line of code (#18194) 2023-05-18 11:23:37 +02:00
yuyi
2bb24ee739 fmt: implement comments inside sumtype declaration (#18189) 2023-05-18 11:22:26 +02:00
yuyi
ddb8e09fec parser, checker: fix generic fn variable assignment in generic fn (#18180) 2023-05-17 03:06:33 +03:00
yuyi
35f2a0fb66 fmt: fix formating of fn decl with end comments (#18181) 2023-05-17 03:05:59 +03:00
Swastik Baranwal
ee7d34e650 checker: allow i32 in enum MyEnum as i32 { (#18172) 2023-05-16 08:09:13 +03:00
Felipe Pena
a7f84e79f8 cgen: fix option unwrap from ovoid function (#18173) 2023-05-14 14:38:14 +03:00
Felipe Pena
d4072bfc22 cgen: fix option with multi return assign (#18174) 2023-05-14 13:50:04 +03:00
Felipe Pena
bfb5a770b2 changelog: update CHANGELOG.md (#18175) 2023-05-14 12:57:31 +03:00
yuyi
814d6823b4 checker: check generic undefined operation (fix #18162) (#18166) 2023-05-13 06:54:08 +03:00
Alexander Medvednikov
1aadd3e59c ci: build news fetcher with -prod 2023-05-13 02:15:58 +02:00
Felipe Pena
47761a42e9 all: attr for enum fields (+ json encode/decode) (#18163) 2023-05-13 01:08:30 +02:00
yuyi
8482bc4626 ast, parser: fix generic fntype to concrete types with later generic fn definition (fix #18156) (#18157) 2023-05-12 15:52:41 +03:00
yuyi
2351856fc3 checker: clean up in struct_init() (#18154) 2023-05-12 09:34:55 +03:00
Turiiya
67e3061ea1 net: fix typos (#18164) 2023-05-12 09:31:27 +03:00
acimnotes
790afbce94 time: add new method year_day and the tests for it (#18107) 2023-05-12 09:27:20 +03:00
Swastik Baranwal
447b45ca8c checker: disallow non-ptr elem in init ptr array (#18161) 2023-05-12 08:56:22 +03:00
Swastik Baranwal
d8cf65df1a checker: only allow &u8 with byteptr and itself (#18146) 2023-05-11 18:28:49 +10:00
yuyi
a87f2d9d11 checker: fix generic struct init with generic struct items (#18152) 2023-05-10 19:06:34 +03:00
yuyi
492a93ecd9 vweb: make controllers of struct Controller public (#18153) 2023-05-10 18:31:43 +03:00
Felipe Pena
d62c4c9fc1 checker: add missing check for global var on assignment to shared var (#18125) 2023-05-10 18:30:57 +03:00
Mark aka walkingdevel
61a5fbea35 autofree: fix cross var assigns with strings (#18147) 2023-05-10 00:06:31 +02:00
Felipe Pena
0be74aa613 cgen: fix option ptr default struct initialization (#18141) 2023-05-09 21:40:51 +03:00
yuyi
9aa5e3fe4b cgen: clean up in index_of_map() (#18145) 2023-05-09 21:12:29 +03:00
yuyi
89f3288fb0 cgen: fix nested map of fn call (#18142) 2023-05-09 16:19:25 +03:00
Turiiya
e2e6c9660c net.html: add &Tag get_tag methods to find first occurrence (#18139) 2023-05-09 00:22:52 +03:00
Felipe Pena
1e56a69c02 checker, parser: save shared/atomic specifier for ast.Param (#18124) 2023-05-09 00:22:22 +03:00
Mark aka walkingdevel
6ac09e605e orm: allow structs without the id field, more flexible primary keys (#18140) 2023-05-09 00:21:42 +03:00
yuyi
72b2f22057 cgen: fix generics array of threads with multiple types (#18137) 2023-05-08 13:24:28 +03:00
yuyi
87623b367c parser: clean up parse_ident() (#18138) 2023-05-08 13:19:03 +03:00
l-m
3a06b55388 wasm: add basic debuginfo through name section (#18130) 2023-05-08 09:31:36 +03:00
Swastik Baranwal
5bdf94a7bc checker: disallow mut for blank idents (#18114) 2023-05-08 01:26:36 +02:00
Alexander Medvednikov
b50dac5e9a changelog: upcoming 0.3.5 changelog 2023-05-07 19:55:27 +02:00
yuyi
a0a8b7e47a ast, parser, checker, cgen, fmt: implement generic fn params (fix #14937) (#18126) 2023-05-07 19:53:56 +02:00
Turiiya
39ec1134fa net.html: fix parsing of nested quoted strings in code tags (#18123) 2023-05-07 03:55:02 +03:00
Felipe Pena
1c3af091f7 cgen, json: fix option ptr declaration and dumping (#18119) 2023-05-07 03:54:43 +03:00
Jacques Supcik
a82fc5bea0 os: make SignalHandler public (#18115) 2023-05-06 14:59:06 +03:00
squidink7
787d774523 checker: warn instead of error, for unnecessary brackets on if/match (#18117) 2023-05-06 14:17:45 +03:00
Petr Makhnev
134e781965 changelog: split items into separate topics (#18112) 2023-05-04 21:24:13 +03:00
Swastik Baranwal
5bcc04e66a checker: disallow _ = <- quit (#18104) 2023-05-04 21:23:34 +03:00
Ikko Eltociear Ashimine
43093311b6 flag: fix typo in flag.v (#18109) 2023-05-04 21:23:02 +03:00
Petr Makhnev
d27b48b7fe changelog: mark encoding enums with their names in json as breaking and that [json_as_number] can be used to get the old behaviour (#18108) 2023-05-04 12:59:46 +03:00
Felipe Pena
5008515b03 builtin: heap memory usage api (#18103) 2023-05-03 20:33:52 +03:00
Mark aka walkingdevel
40a97aed1a docs, orm: update examples (#18106) 2023-05-03 20:33:16 +03:00
Felipe Pena
2c123dffbb cgen: fix comptimeselector option propagation (#18092) 2023-05-03 08:31:48 +03:00
Mark aka walkingdevel
458132b1b2 checker: make undefined ident error for closures more friendly (#18100) 2023-05-03 08:02:59 +03:00
Thomas Peißl
353de60158 examples: fix unset reader notice for the smtp/mail example (#17998) 2023-05-02 22:54:57 +03:00
Casper Kuethe
d3dbd7b743 vweb: add docs for [vweb_global] and shared attributes. (#18098) 2023-05-02 22:49:55 +03:00
Felipe Pena
063dfa0ab9 checker: missing mutability check for array.delete calls (#18096) 2023-05-02 22:48:40 +03:00
Delyan Angelov
5631e2f01d ci,cgen,orm: fix CI failures after 9f118ba 2023-05-02 21:29:58 +03:00
Alexander Medvednikov
9f118ba3f1 orm: skip via the "-" attribute 2023-05-02 17:00:54 +02:00
Alexander Medvednikov
b9f5cc830b json: skip via the "-" attribute 2023-05-02 16:41:32 +02:00
Felipe Pena
638f0f69ed checker: fix wrong error message about missing shared on parameter signature (fix #18087) (#18091) 2023-05-02 15:52:40 +03:00
Delyan Angelov
f25ad18851 .cirrus.yml: only run slow FreeBSD builds on changes to .v and .vsh files, not .md ones 2023-05-02 15:42:19 +03:00
Petr Makhnev
c8568a29dc changelog: fix wording about backends and C++20 support (#18097) 2023-05-02 15:26:19 +03:00
Swastik Baranwal
c4cce3bc00 checker: disallow matching type with primitive vars (#18084) 2023-05-02 11:40:38 +03:00
Mark aka walkingdevel
ca2820da5f checker, orm: don't insert an uninitialized struct in the related table. (#18093) 2023-05-02 11:14:42 +03:00
Christopher Fore
b255fef686 tools: update v share to work with the playground redesign (#18090) 2023-05-01 09:10:52 +02:00
Alexander Medvednikov
e4e94acf15 changelog: fix typos 2023-05-01 00:02:29 +02:00
Alexander Medvednikov
046dd5481c V 0.3.4 2023-05-01 00:58:10 +03:00
Alexander Medvednikov
2f441a8102 changelog: 0.3.4 (p.2) 2023-04-30 22:57:17 +03:00
Casper Kuethe
0898f57995 net.html: fix text parsing for inline tags (#18085) 2023-04-30 16:20:24 +03:00
Felipe Pena
d086cc26cd cgen: fix it variable casting on map call when arr is a comptime variable #18083 2023-04-30 16:18:44 +03:00
Alexander Medvednikov
580e079b1e changelog: 0.3.4 (p.1) 2023-04-29 22:37:27 +03:00
Felipe Pena
e738d671a5 checker: fix [noinit] attr checking with multiple attr (#18079) 2023-04-29 17:07:24 +03:00
Mark aka walkingdevel
e8df5a7861 checker: check db type implements orm.Connection and isn't an Option. (#18078) 2023-04-29 10:36:21 +02:00
Mark aka walkingdevel
9eee131423 checker: make type_implements() return false if methods of interface didn't implement (#18076) 2023-04-28 22:18:23 +03:00
Felipe Pena
2f48288a25 checker: fix generic argument resolution for multiple generic args (#18073) 2023-04-28 17:06:28 +03:00
Felipe Pena
b6bbd2463c cgen: fix shared struct field initialization with default value (#18075) 2023-04-28 16:59:18 +03:00
Hitalo Souza
b0589c645d json2: encode reference fields too (#17058) 2023-04-28 16:24:27 +03:00
Spydr
433208ea7e native: make code generation logic platform-independant (#18057) 2023-04-28 16:00:23 +03:00
Turiiya
27e1c20e3d toml: fix multiline array bool scanner, add test (#18068) 2023-04-28 01:30:47 +03:00
Mark aka walkingdevel
b767c7d6f5 cgen: orm: refactor, comments, simplify (#18070)
* cgen: refactor, comments, simplify

* fix: misc-tooling
2023-04-28 01:30:23 +03:00
Swastik Baranwal
30ac2e8763 checker: disallow assigning anon struct to typed struct (#18017) 2023-04-27 16:54:26 +02:00
Felipe Pena
9fb52c4c9c cgen: fix code generated for or-block for void result return function + code generated for indirection comptime checking for logical operators (#18066) 2023-04-27 17:37:29 +03:00
Felipe Pena
ee9cfb6df4 checker: add check for mixing multi-return results with other types in return statements (fix #17501) (#18067) 2023-04-27 16:50:09 +03:00
Turiiya
bbfa25a17b toml: fix scanner floating point detection (#18062) 2023-04-27 06:43:00 +03:00
Turiiya
8f767c9189 toml: update returns from option to result type (#18065) 2023-04-27 06:41:40 +03:00
Felipe Pena
c63902baf0 checker, cgen: fix generic resolution for comptimeselector and indirection checking on generic funcs (#18043) 2023-04-26 22:49:50 +03:00
yuyi
f4b7f83121 parser, checker: fix generic struct init with field struct init (#18052) 2023-04-26 22:22:15 +03:00
Felipe Pena
13b4cd9d58 os: fix memleak from getline on Linux (#18022) 2023-04-26 22:02:09 +03:00
yuyi
e1e5076d94 cgen: fix cross assign with generic fn call (#18050) 2023-04-26 20:41:20 +03:00
Felipe Pena
28f85371b1 cgen: fix comptime ptr comparison generated code (#18048) 2023-04-26 20:40:28 +03:00
squidink7
4bfe270c41 wasm: add support for [export]ed functions (#18055) 2023-04-26 20:39:58 +03:00
Jacques Supcik
c4b34c9482 docs: fix copy/paste leftover in the output of v help build-c (#18056) 2023-04-26 08:59:20 +03:00
Turiiya
b87ddf68ae docs: add concise control flow example for if x := expr { (#17983) 2023-04-25 07:07:28 +03:00
Spydr
3622544695 native: implement miscellaneous features (#18044) 2023-04-25 01:19:15 +03:00
Arnaud Moura
88b29ae178 doc: create custom problemMatcher in VSCode (#18047) 2023-04-25 01:18:57 +03:00
Swastik Baranwal
ac58eca015 checker: disallow deferencing a nil pointer (#18038) 2023-04-25 01:10:01 +03:00
yuyi
f598bbde4e tests: clean up c_struct_with_reserved_field_name_test.v (#18026) 2023-04-24 11:04:13 +02:00
yuyi
79819c4fcb parser: check generic fntype declaration without type name (#18033) 2023-04-24 11:03:29 +02:00
Spydr
7ac7020192 native, markused: implement -skip-unused (#18036) 2023-04-24 10:41:12 +02:00
yuyi
d8167b8966 ast, parser: fix generic fntype to concrete types (fix #17982) (#18025) 2023-04-23 03:44:16 +03:00
Hitalo Souza
cd90bc65b8 tools/vcreate: fix web app (#18019) 2023-04-23 03:43:40 +03:00
Mark aka walkingdevel
3fb32a866c all: like operator/keyword for V ORM (#18020) 2023-04-23 03:40:54 +03:00
Casper Kuethe
5f870f41b5 vweb: implement database pool (#18010) 2023-04-23 03:37:15 +03:00
Felipe Pena
6f85384f7f checker, cgen: fix infering type for comptimeselector when using ptr type (#18005) 2023-04-22 11:04:08 +03:00
Felipe Pena
3d50663bcf json: fix omitempty for alias, struct, sumtype, array and map (#18012) 2023-04-22 10:58:21 +03:00
Felipe Pena
89b7bebc3c json: fix option sumtype with int types (#18013) 2023-04-22 10:58:01 +03:00
Felipe Pena
c43ea09d87 json: fix -cstrict build + optional map (#18014) 2023-04-22 10:55:25 +03:00
Artem Yurchenko
4c54f36a70 github: add Copilot summary and walkthrough to PR template (#18016) 2023-04-22 10:54:26 +03:00
Felipe Pena
c339ea2ce2 checker, cgen: make comptime field.indirections working with logical operators (#17990) 2023-04-21 19:43:47 +03:00
Felipe Pena
59d91e0514 cgen: fix auto_str for fn type (#17988) 2023-04-21 19:42:45 +03:00
Petr Makhnev
d48aa15514 tools/vcheck-md: add -skip_line_length_check flag and fix vmod handling in '```vmod' (#17997) 2023-04-21 19:42:21 +03:00
yuyi
95d1beb008 cgen: fix c struct with reserved field name (fix #17993) (#17996) 2023-04-21 19:41:13 +03:00
Felipe Pena
488e14bf99 json: allow decode/encode of alias to primitive type (#18003) 2023-04-21 19:39:40 +03:00
Swastik Baranwal
456968b07d checker: disallow []array{} (#17994) 2023-04-21 19:33:23 +03:00
yuyi
eb410bf283 checker: minor cleanup in return_stmt() (#17995) 2023-04-21 19:32:59 +03:00
Felipe Pena
adcd16b198 cgen: fix generic return for option ptr (#17987) 2023-04-18 17:51:43 +02:00
Felipe Pena
377c2e25ff all: allow recursive struct with option ptr (?&Node) (#17682) 2023-04-18 13:07:21 +02:00
yuyi
6cc420880f ast, checker, cgen: fix generic array of threads (fix #17976) (#17986) 2023-04-18 12:43:30 +03:00
Felipe Pena
df3ee9a64a cgen: fix concat with matchexpr + option string (#17985) 2023-04-18 12:40:37 +03:00
Felipe Pena
8445642567 cli: fix a panic and an infinite loop, when command flag descriptions have multiple lines (#17981) 2023-04-18 12:37:26 +03:00
Turiiya
a84fddbb91 toml: fix trailing comma in inline toml, add test (#17977) 2023-04-18 12:35:55 +03:00
Mehmet Ali Şipi
04dabb5485 v.builder: add support for cross-compilation from termux to other platforms (#17984) 2023-04-18 09:20:17 +03:00
Delyan Angelov
8275dc5a73 db.pg: add support for -d trace_pg_error 2023-04-17 21:49:05 +03:00
Felipe Pena
3b2e58eace checker: fix missing check for or-block on selectorexpr (#17975) 2023-04-17 16:11:34 +02:00
yuyi
fe4ccbc4cf cgen: fix strings builder shift array.reverse() (#17979) 2023-04-17 14:06:57 +03:00
Delyan Angelov
4a22d4a65d checker: fix v -shared vlib/json on windows 2023-04-17 09:12:05 +03:00
Delyan Angelov
bf749b3559 ci: add test jobs for the wasm module, for macos, linux and windows (#17972) 2023-04-16 14:52:00 +03:00
Felipe Pena
a49cecc2b4 cgen: fix array map with it selector expr, used as an it method closure (#17968) 2023-04-16 14:41:07 +03:00
Felipe Pena
8e959ae5b5 parser: fix wrong nodes generated for $something (#17969) 2023-04-16 14:36:51 +03:00
Turiiya
6e0204a614 regex: remove outdated examples in README.md (#17971) 2023-04-16 13:17:24 +03:00
yuyi
6db904fb8f cgen: correct comments and cleanup in comptime_for() (#17964) 2023-04-16 08:01:36 +03:00
Swastik Baranwal
d3de7adcc0 builtin: add C.scanf fn decl to cfns.c.v (#17965) 2023-04-16 08:00:19 +03:00
Delyan Angelov
75ddcb02fc tests: fix warnings and failure on macos for closure_generator_test.v 2023-04-16 07:45:05 +03:00
yuyi
a938dcddb5 ast: minor cleanup in ast.v (#17962) 2023-04-15 14:29:15 +03:00
yuyi
7c9f273e33 parser: fix comptime_for in repl (script mode) (fix #5976) (#17963) 2023-04-15 14:28:01 +03:00
James Hegedus
2179db37ee flag: fix typo in uknown flag struct (#17375) 2023-04-14 14:42:11 +03:00
SolarWolf-Code
7981d2854a net: fix typo give => given (#17955) 2023-04-14 11:15:16 +03:00
Delyan Angelov
e0656ad1b1 term.ui: cleanup of meaningless comment 2023-04-14 11:13:50 +03:00
Alexander Medvednikov
9f5e2aeea9 backtrace: use unsafe { nil } 2023-04-14 08:28:22 +02:00
yuyi
c59a5bbf05 parser: clean up array_init() (#17947) 2023-04-14 07:36:57 +02:00
Casper Kuethe
76fd55a693 vweb: fix multipart_form parsing (#17953) 2023-04-14 07:07:48 +02:00
l-m
8b2887d80b wasm module: globals, constant expressions and function reference types (#17950) 2023-04-13 19:39:55 +02:00
Delyan Angelov
093e5c68b9 ci: bump performance-regressions max_time limit to 1701, to reduce chance of false positive failures from slow CI runners 2023-04-13 19:10:00 +03:00
Delyan Angelov
c6947fde57 os: implement Process.set_work_folder/0 to set the initial working folder of the new child process (#17946) 2023-04-13 14:48:32 +03:00
Turiiya
489ac892b9 regex: fix formatting inconsistencies in README.md (#17940) 2023-04-13 14:44:45 +03:00
Felipe Pena
524f7c3ead json: fix json with option struct (#17942) 2023-04-13 08:17:40 +02:00
Swastik Baranwal
3d99f1f2c2 checker: disallow struct int to ptr outside unsafe (#17923) 2023-04-13 07:38:21 +02:00
yuyi
92cb7468ce ast: minor optimization of clear_flags() (#17938) 2023-04-13 07:27:26 +02:00
yuyi
87ca877c83 parser: correct comments in comptime_for() (#17944) 2023-04-13 07:26:43 +02:00
SolarWolf-Code
f41ca48ab9 doc: one hour => one weekend (#17937) 2023-04-12 06:53:07 +03:00
Casper Kuethe
838083e610 vweb: add an overridable .not_found() method, for making a custom 404 page + tests fixes (#17936) 2023-04-12 00:50:03 +03:00
lapingenieur
f9c186a400 builtin: correct a small documentation mistake (#17935) 2023-04-11 12:37:14 +02:00
yuyi
8b37694760 cgen: fix generic method on embed struct (fix #17929) (#17932) 2023-04-11 10:04:00 +03:00
Hitalo Souza
91874f3244 json2: encode array (#17926) 2023-04-10 19:54:43 +03:00
Felipe Pena
319ad5bae2 json: fix json.decode with map alias (#17925) 2023-04-10 19:50:35 +03:00
Hitalo Souza
624f1592a8 examples: create readme.md for vweb_fullstack (#17928) 2023-04-10 19:20:03 +03:00
Hitalo Souza
4d4d76d65b json2: fix encoding of nested maps like map[string]map[string]int (#17924) 2023-04-10 18:57:02 +03:00
yuyi
4e498b4303 cgen: fix printing array of recursive reference struct (fix #17858) (#17922) 2023-04-10 17:09:27 +03:00
Felipe Pena
6a60db8768 cgen, checker: fix generic/comptime parameter concrete type resolution in some cases (#17762) 2023-04-10 10:42:49 +03:00
Felipe Pena
063f4023c5 checker: allow mut var.$(field.name) (#17911) 2023-04-10 10:37:02 +03:00
Felipe Pena
5c439b6621 cgen: fix auto_str for option values (#17910) 2023-04-10 05:56:57 +02:00
Alexander Medvednikov
220b31bfba roadmap: 64/32 bit int 2023-04-10 05:01:01 +02:00
Alexander Medvednikov
83afa1009e checker: fix immutable deref check 2023-04-10 04:59:36 +02:00
Artem Yurchenko
88f89bde4e doc: improve in documentation for maps (#17918) 2023-04-09 13:43:13 +02:00
Swastik Baranwal
6acf01a4a0 checker: disallow more reserved types to be used as variable names (#17917) 2023-04-09 13:42:21 +02:00
Surman The Dead
b772731b98 leb128: make decoding return the number of decoded bytes, in addition to the decoded value (#17912) 2023-04-09 10:32:49 +03:00
Delyan Angelov
abe0ad886b ci: workaround flakyness of array_test.v on windows, with the default GC mode 2023-04-09 09:48:15 +03:00
Delyan Angelov
9267e41337 cgen: fix v -prealloc file_test.v 2023-04-09 09:35:43 +03:00
l-m
d2f69472b2 vlib: add a wasm module, implementing a pure V webassembly seralisation library (#17909) 2023-04-09 07:55:02 +03:00
penguindark
9658d20f03 strconv.atoi: optimization (#17913) 2023-04-09 05:54:38 +02:00
Delyan Angelov
fdc22b9020 ci: mark array_access_optimisation_test.v as flaky, and retry it 3 times 2023-04-09 06:32:28 +03:00
Delyan Angelov
cd629cfeab cgen: do not generate the stringified values for assert x in y, for the pass case (#17908) 2023-04-08 18:51:46 +03:00
Delyan Angelov
ebfc4b4663 builtin: remove test for the deprecated []int.reduce/2 2023-04-08 18:47:04 +03:00
l-33ter
756e5d931e examples/vweb_fullstack: fix wrong db ORM-fields (#17907) 2023-04-08 17:18:48 +03:00
Delyan Angelov
48d42287a9 v.markused: enable v -skip-unused -live run examples/hot_reload/bounce.v 2023-04-08 14:36:01 +03:00
yuyi
e70084f203 ast: clean up ast.v, table.v and types.v (#17906) 2023-04-07 16:58:34 +03:00
lemon
e300fb428a math: add maxof[T]() and minof[T]() (#17905) 2023-04-07 15:48:37 +03:00
yuyi
237f9446e2 checker, cgen: fix type alias of pointer (#17904) 2023-04-07 10:19:25 +02:00
Alexander Medvednikov
eb6dd82d72 doc: simplify custom error example 2023-04-07 07:12:13 +02:00
Swastik Baranwal
65abfa8219 checker: disallow printing void (#17901) 2023-04-07 06:40:11 +02:00
Alexander Medvednikov
bb280121e3 sokol: bring back command q on macos 2023-04-07 04:08:28 +02:00
Petr Makhnev
812a17fb43 tests: use isreftype[T]() and sizeof[T]() syntax, fix vfmt to support them, when written explicitly (#17103) 2023-04-06 20:02:55 +03:00
Felipe Pena
1113205376 json: fix [raw] for option string (#17899) 2023-04-06 18:26:17 +03:00
Subhomoy Haldar
a773e44430 rand: update documentation for normal and normal_pair (#17898) 2023-04-06 17:52:09 +03:00
Ikko Eltociear Ashimine
7838ef366a crypto.pem: fix typo in decode.v (#17896)
seperator -> separator
2023-04-06 12:12:45 +03:00
yuyi
31ffbc7a87 scanner: fix string interpolation string literal with fmt (#17895) 2023-04-06 12:11:15 +03:00
Casper Kuethe
930bdd935b vweb: fix static files copying (#17891) 2023-04-06 03:10:23 +02:00
walking devel
9957356a84 encoding.base32: change ? to ! (#17892) 2023-04-06 03:09:05 +02:00
Felipe Pena
b4e8e812fe json: fix encode/decode fixed array (#17887) 2023-04-06 01:15:23 +03:00
Delyan Angelov
dce65c7f46 tools: make v watch webserver.v monitor files used through $tmpl as well 2023-04-06 00:45:25 +03:00
Felipe Pena
7334f673a0 cgen: fix cast option ptr (#17884) 2023-04-05 22:29:18 +03:00
Swastik Baranwal
902d0dc93d checker: allow ~T(0) where T is int (#17886) 2023-04-05 13:05:18 +03:00
Surman The Dead
39b3a0ca17 encoding: add an encoding.leb128 module with tests (#17880) 2023-04-05 11:53:25 +03:00
ChAoS_UnItY
b2cf6d0af4 cgen: fix wrong indent generation in anon fn decl (#17879) 2023-04-05 11:22:36 +03:00
Swastik Baranwal
d30e1a52e2 checker: disallow unwrapped option/result with in operator (#17875) 2023-04-05 11:20:42 +03:00
walking devel
fc4c431d83 v: rename sql.v -> orm.v for consistency (#17877) 2023-04-04 22:35:52 +03:00
yuyi
467a1b4435 fmt: remove redundant parenthesis in the complex infix expr (#17873) 2023-04-04 13:47:48 +03:00
walking devel
8452644ec3 orm: enforce that queries always return a Result, a query-resulting array can be used as a V array in place. (#17871) 2023-04-04 08:23:06 +03:00
l-33ter
9addede0ea readline: README.md change '?' to '!' (#17868) 2023-04-04 02:51:30 +03:00
yuyi
4f532c0830 checker: fix fn returning alias of pointer (fix #17861) (#17864) 2023-04-03 19:32:55 +03:00
Swastik Baranwal
1dcec62c19 checker: disallow top level decl builtin fn (#17857) 2023-04-03 17:30:05 +03:00
yuyi
22afdb5cbf cgen: fix gen_str_for_map() (#17862) 2023-04-03 14:42:01 +03:00
yuyi
a9bb6865fd scanner: fix checking comments not terminated (fix #17842) (#17855) 2023-04-03 14:37:52 +03:00
yuyi
33ba24e933 scanner: fix nested multiline comments (#17859) 2023-04-03 14:35:27 +03:00
Delyan Angelov
88de0decf6 v.pref: allow passing file names to v scripts, that use -raw-vsh-tmp-prefix, without showing a Too many targets error message. 2023-04-03 05:07:12 +03:00
ChAoS_UnItY
de34e15df7 cgen: fix multi return variable ignore in if guard (#17853) 2023-04-02 15:47:54 +02:00
Swastik Baranwal
01caecc284 checker: add check for unwrapped option in array cap (#17851) 2023-04-02 15:47:08 +02:00
Casper Kuethe
b2735bf937 vweb: add controllers (#17840) 2023-04-02 15:46:43 +02:00
ChAoS_UnItY
c7237b1c58 cgen: fix result of typeof function returns result type (#17849) 2023-04-02 02:25:34 +02:00
Josh Montoya
51ad565ed6 vweb: implement worker pool (#17298) 2023-04-02 01:24:33 +02:00
Felipe Pena
1471ba4678 checker: fix missing check for initializer with function returning options (#17820) 2023-04-02 00:03:42 +03:00
Delyan Angelov
6aec8244f0 strings: simplify Builder.drain_builder; add test (#17846) 2023-04-02 00:03:00 +03:00
Delyan Angelov
58dd9ee6a2 tests: make the flaky array_access_optimisation_test.v failures on the macos CI, more easily diagnosable 2023-04-01 17:33:44 +03:00
Felipe Pena
5b8d6c0a60 cgen: fix match tmp var needing check when working with option on branches (#17837) 2023-04-01 08:19:23 +03:00
Delyan Angelov
e56e4b3e90 tools: use os.symlink(vexe, vsymlink) on Windows too (#17838) 2023-04-01 08:18:24 +03:00
Spydr
fedf0f7939 native: rune type literals/printing, pointer comparison and some missing branches in functions (#17839) 2023-04-01 01:09:02 +03:00
yuyi
e1b8617c94 ast, cgen: fix generic closures with different generic types (fix #17829) (#17834) 2023-03-31 18:08:42 +03:00
yuyi
6ff1c0a0b2 checker: fix generic struct init with update expr (fix #17824) (#17827) 2023-03-31 10:59:52 +03:00
ChAoS_UnItY
ff0adba8a9 tests: fix file partially not fmt, caused by fixed vfmt bug (#17828) 2023-03-31 10:22:31 +03:00
Felipe Pena
cd6cc65ece json: fix [omitempty] with string (#17813) 2023-03-30 23:09:47 +03:00
Delyan Angelov
57aa4def62 net.html: do not inject <text> tags for text that contains only newlines and spaces 2023-03-30 23:02:57 +03:00
Delyan Angelov
822acd78cb tools: add test for VDOC_SORT=false ./v doc file.v 2023-03-30 16:53:12 +03:00
yuyi
b40aa4ffa9 cgen: fix embed struct with sumtype field (#17823) 2023-03-30 15:59:06 +03:00
Delyan Angelov
214f72ba03 tools: support VDOC_SORT=false ./v doc time 2023-03-30 14:35:54 +03:00
yuyi
b9352ce834 ast, parser, fmt: fix fmt error of generic fntype (#17814) 2023-03-30 13:30:10 +02:00
yuyi
d0702f3897 checker: fix if cond with alias (fix #17818) (#17821) 2023-03-30 13:29:08 +02:00
Delyan Angelov
4ef6e16e3b bitfield: add [inline] for very commonly used simple methods 2023-03-30 11:53:02 +03:00
Delyan Angelov
ae6fc64fb3 ci: bump the timeout to 181 minutes for the windows-msvc and windows-gcc jobs 2023-03-30 09:01:15 +03:00
Thomas Mangin
580d9cedc7 termios: new termios module (#17792)
* termio: new termio module

move the tcgetattr and tcsetattr functions in a new termio module.
The code needed refactoring as different OS have different fields
size, position and number for the C.termios structure, which
could not be correctly expressed consitently otherwise.

It has the positive side effect to reduce the number of unsafe calls.
New testing code was also added for the readline module as it is
relying of the feature.

* apply 2023 copyright to the new files too
2023-03-30 08:58:52 +03:00
Alexander Medvednikov
0826102e0a sokol: enable VALIDATE_NON_FATAL 2023-03-30 00:10:49 +02:00
Alexander Medvednikov
d60ceb45cd gg: make create_image() return !Image 2023-03-29 19:04:41 +02:00
Felipe Pena
75deb66fd4 json: fix decode option string (#17812) 2023-03-29 18:45:41 +02:00
yuyi
dd0b68ac90 checker: check if guard returning non-propagate option or result (fix #17742) (#17794) 2023-03-29 14:51:29 +03:00
Alexander Medvednikov
6756d28595 all: 2023 copyright 2023-03-28 22:55:57 +02:00
Alexander Medvednikov
ed21097a91 doc: document json anonymous struct fields 2023-03-28 22:55:28 +02:00
Casper Kuethe
1f613a082a vweb: use net.http.Cookie (#17807) 2023-03-28 22:27:01 +02:00
Artem Yurchenko
53e4085ddc doc: fix documentation examples (#17804) 2023-03-28 22:26:22 +02:00
Delyan Angelov
ff5df2ce07 cgen: small cleanup in comments (init: it -> init: index) 2023-03-28 15:06:06 +03:00
yuyi
4007c6cf89 checker: check generic struct infering error (#17802) 2023-03-28 15:00:08 +03:00
Felipe Pena
db8331da24 cgen: fix fixed array of string item concatenation (#17801) 2023-03-28 14:56:54 +03:00
yuyi
da153aa780 checker, cgen: fix asserting if guard expr (#17793) 2023-03-28 11:40:33 +03:00
Alexander Medvednikov
5e48817dc8 parser: remove duplicated pascal case check 2023-03-27 13:38:21 +02:00
Heptalon
6b4fb0fc3e checker: fix missing check for option value on non-optional struct field assignment (#17785) 2023-03-27 04:11:56 +02:00
yuyi
f08b88223d checker: fix returning error in if expr (#17783) 2023-03-26 18:10:06 +02:00
yuyi
130f35c776 checker: fix embedded struct field with default value (#17777) 2023-03-26 11:33:01 +03:00
ChAoS_UnItY
34f5f05efa ast: fix concrete fn type that returns pair type as generic type (#17780) 2023-03-26 11:29:52 +03:00
Subhomoy Haldar
8759409a69 math.big: fix min i32 value bug (#17775)
* attempt big int min value fix

* cast value for correct comparison

* update edge case

* add one more test
2023-03-26 08:45:42 +03:00
Casper Kuethe
1fe5aca782 vweb: middleware implementation (#17730) 2023-03-26 00:57:42 +01:00
Artem Yurchenko
713c95fcc8 Fix: vet false warning on brackets in documentation (#17767) 2023-03-25 21:51:45 +02:00
Delyan Angelov
db97630117 examples, orm: fix orm example; add -d trace_orm option to see all ORM generated queries (#17770)
* orm: add tracing of the generated queries by the orm module, when a program is compiled with `-d trace_orm`

* examples: fix examples/database/orm.v, add comments, and ensure that the example can be run several times with no errors

The example demonstrates connecting to all 3 DBs in the same program, and will be added to the CI very soon,
to serve both as a regression test, if it fails, and as an example to how to use the ORM in combination with
raw SQL queries to the DBs (which are driver/wrapper specific, unlike the ORM, but can be more convenient in some situations).
2023-03-25 21:46:17 +02:00
ChAoS_UnItY
f5f45d846e ast: fix concrete function type used as generic type (#17769) 2023-03-25 21:45:19 +02:00
penguindark
3d2d330478 regex: fix issue with multiple repetitions out of the groups (#17774) 2023-03-25 20:49:01 +02:00
Felipe Pena
24cc5920e6 cgen: multiple auto equality func generated fixes (#17756) 2023-03-25 20:45:18 +02:00
Swastik Baranwal
0a8a0fdb0e checker, cgen: fix check and cgen for match x { StructName {} } and match x { y {} }, where x is a mutable receiver (#17755) 2023-03-25 14:38:47 +02:00
yuyi
17c4eb49fb parser: clean up in parse_generic_inst_type() (#17766) 2023-03-25 08:39:23 +02:00
yuyi
a9f55de352 checker: fix generic array delete in skip_unused mode (#17759) 2023-03-25 08:31:25 +02:00
Felipe Pena
ca198ace7d cgen: fix nested fn call with result/option propagation (#17738) 2023-03-24 17:36:37 +02:00
Hitalo Souza
dc11f1fe05 json2: fix decode to map doesn't work (#17757) 2023-03-24 17:30:32 +02:00
Hitalo Souza
979066856b json2: encode map (#16928) 2023-03-24 13:45:26 +02:00
Delyan Angelov
bfb0932588 net.http.mime: execute v run vlib/net/http/mime/build.vsh to update db.v with the latest official mime types 2023-03-24 08:29:32 +02:00
Delyan Angelov
37a79624fc cgen: fix println(value.name) inside $for value in Test.values{ (#17746) 2023-03-23 19:18:25 +02:00
Felipe Pena
8693da4d36 parser: fix parsing cast array syntax from another module (fix #17704) (#17739) 2023-03-23 18:26:12 +02:00
yuyi
6b5c746146 ci: fix comptime_concrete_type_register_test.v after 9a9cfe4 (#17744) 2023-03-23 16:42:35 +02:00
Felipe Pena
9a9cfe425c all: comptime type lowercase ($int, $enum, $option, etc) (#17732) 2023-03-23 00:02:42 +01:00
Felipe Pena
0afb41f7e1 checker: fix missing type mismatch with ptr types (#17695) 2023-03-22 23:49:02 +01:00
Felipe Pena
a552a79ca8 checker: fix comptime concrete type register (fix #17657) (#17659) 2023-03-22 16:16:19 +02:00
Alexander Medvednikov
828b8097d0 roadmap: vweb 2023-03-22 13:02:20 +03:00
Felipe Pena
278e747c7a json: make enums work with json encode+decode (serialised as string names by default; the old integer one is supported too, using [json_as_number]) (#17696) 2023-03-22 10:33:32 +02:00
Felipe Pena
c9345be6de ast: fix embed name with enum as generic struct type (fix #17721) (#17727) 2023-03-22 09:50:58 +02:00
walking devel
d0e78b1da6 parser: breaking change, let V ORM queries return arrays for *all* non-count queries, including limit = 1 (#17719) 2023-03-22 09:48:01 +02:00
Swastik Baranwal
93b7cc4888 cgen: allow using of original operation if alias is number and no custom method is defined (#17718) 2023-03-21 11:39:58 +02:00
Felipe Pena
326e43385b cgen: fix match with option type (#17713) 2023-03-21 11:38:30 +02:00
d3c0d3d.exe
54a1b66b94 os: add create_no_window parameter to Process (#17726) 2023-03-21 11:24:40 +02:00
yuyi
e1d4539a14 cgen: clean up comments in cgen.v (#17725) 2023-03-21 12:07:25 +03:00
yuyi
968b519be5 checker: implement infering generic struct types (#17717) 2023-03-20 20:42:53 +02:00
Louis Brunner
977cd0d8df cgen: better alias handling for references/shared (#17656) 2023-03-20 17:35:45 +01:00
DJ-Dav
e7996a0792 tools: fix vls error unexpected token U in JSON (#17709) 2023-03-20 14:40:52 +02:00
Felipe Pena
17fe76368a regex: fix simple char match (#17701) 2023-03-20 10:37:09 +02:00
Felipe Pena
74eac1de4e parser: fix parsing array of options from a submodule (#17714) 2023-03-20 10:36:22 +02:00
Alexander Medvednikov
f1e9a8ff37 tests: remove unnecessary v_printf test 2023-03-19 15:30:52 +03:00
Alexander Medvednikov
47e10a9fcd strconv: make v_printf private 2023-03-19 15:03:49 +03:00
Alexander Medvednikov
7939ca2997 strconv: deprecate v_sprintf 2023-03-19 11:30:56 +03:00
yuyi
c18bf48833 cgen: fix closure with fixed array variable (#17707) 2023-03-19 10:11:11 +02:00
Casper Kuethe
37af8bbd27 vweb.assets: add option for custom href and src attribute values (#17703) 2023-03-19 10:02:59 +02:00
yuyi
9275161d0f strconv: fix v_sprintf with '%%' (#17708) 2023-03-19 09:52:45 +02:00
Delyan Angelov
3793bf1c99 builtin: optimise the common case of s.contains("x") add s.contains_byte(x) (#17702) 2023-03-19 01:10:13 +03:00
yuyi
14148f3e52 toml: clean up autocast in parser.v (#17662) 2023-03-18 23:15:00 +03:00
Felipe Pena
2df23a6698 json: fix ptr field access (#17690) 2023-03-18 14:47:40 +02:00
Brandon
aee76c5819 net: update new_request (#17618) 2023-03-17 22:17:22 +01:00
yuyi
268cee82fc cgen: fix map of complex array (#17660) 2023-03-17 22:12:59 +01:00
yuyi
24ea00da0c checker: clean up infer_struct_generic_types() and infer_fn_generic_types() (#17668) 2023-03-17 21:46:56 +01:00
Felipe Pena
9e7aeec215 sql: fix wrong field name on generated code (#17684) 2023-03-17 21:45:52 +01:00
Felipe Pena
68955bb26c cgen: fix indexexpr with complex index expr (#17693) 2023-03-17 21:44:14 +01:00
yuyi
45c0a21f46 checker: clean up assign_stmt() (#17664) 2023-03-17 21:43:38 +01:00
yuyi
88ab947440 cgen: fix spawn method on generic struct (#17691) 2023-03-17 21:43:04 +01:00
Artem Yurchenko
608c194325 doc: [packed] and [minify] attributes documentation (#17692) 2023-03-17 21:41:48 +01:00
ArthurZhou
8c35ee0722 vweb: add an option to disable startup message (#17645) 2023-03-17 21:41:25 +01:00
Felipe Pena
2c349247e1 checker: fix anon fn initialization as struct-like (#17652) 2023-03-17 21:41:00 +01:00
Delyan Angelov
6e1e406288 vweb: implement live page reload in development, based on polling (useful with watch) (#17683) 2023-03-16 21:00:47 +01:00
Felipe Pena
658b116d07 checker: fix wrong struct warn about inited fields (#17678) 2023-03-16 21:42:00 +02:00
Felipe Pena
6709b2de0f cgen: fix selector expr with alias to ptr (#17649) 2023-03-16 21:32:52 +02:00
Felipe Pena
25eabf8e2d cgen: fix argument dereference for str method when receiver is ptr (#17648) 2023-03-16 21:28:14 +02:00
Felipe Pena
f5b67802fd cgen: fix push operation on array of option (#17658) 2023-03-16 21:24:48 +02:00
yuyi
d349c1d86d checker: check generic fn call argument type mismatch (#17680) 2023-03-16 21:19:03 +02:00
Felipe Pena
b345d77805 json: support field &Type (#17655) 2023-03-16 21:15:14 +02:00
Felipe Pena
5eb331ed89 cgen: fix option ptr printing (#17651) 2023-03-16 13:02:39 +02:00
Felipe Pena
7e8723d603 cgen: fix multi return assignment with option (#17676) 2023-03-16 12:59:49 +02:00
Felipe Pena
93a2ffa9ef cgen: fix fixed array assignment from unsafe block (#17647) 2023-03-15 20:30:49 +02:00
Felipe Pena
39e80afab0 checker: fix missing check for wrong assignment: non-option to option type (#17628) 2023-03-15 20:24:36 +02:00
yuyi
d290f432d1 ast: clean up resolve_init() (#17663) 2023-03-15 17:20:04 +02:00
Felipe Pena
2656ce9522 checker: fix missing check for [export] attr on a fn, without parameter (#17653) 2023-03-15 17:17:45 +02:00
yuyi
aa50f4ebf7 checker: clean up sum_type_decl() (#17669) 2023-03-15 16:56:41 +02:00
Delyan Angelov
2e7dd8543a ci: fix failing vlang/vpm test jobs 2023-03-15 16:54:16 +02:00
Delyan Angelov
8e9e91be7e builder: add a separate ALL_FRONT_STAGES timing metric 2023-03-15 15:14:58 +02:00
Felipe Pena
b71c131678 cgen: fix map with comp-time reflection, improve comptime var handling (#17603) 2023-03-14 13:49:29 +02:00
yuyi
2643d6645f ast, parser, cgen: fix generic struct init with inconsistent generic types (#17639) 2023-03-14 13:24:52 +02:00
Delyan Angelov
cb7e25e47e sokol.gfx: update the C.sg_pass_attachment_desc declaration to match the one from the Sokol headers 2023-03-14 09:02:03 +02:00
Heptalon
618c92a13b urllib: change Values.get to return an option type (#17636) 2023-03-14 08:44:40 +02:00
Delyan Angelov
daa9034583 os: return the long path for os.temp_dir() on windows, even for folders like c:\someth~1 (#17623) 2023-03-14 00:51:52 +02:00
Felipe Pena
d1d26893f5 parser: fix option struct init decl with module prefix (#17615) 2023-03-14 00:50:06 +02:00
Artem Yurchenko
f18cc6ebb0 vfmt: remove spurious src. prefix, from import name becoming import src.name (#17633) 2023-03-14 00:00:41 +02:00
Delyan Angelov
42732138c6 v: support -ldflags in addition to -cflags (allow adding C options *after* other C option, similar to LDFLAGS) (#17630) 2023-03-13 21:38:48 +02:00
Felipe Pena
9ad1c2f922 checker: fix missing option function field checking (#17601) 2023-03-13 15:05:56 +01:00
Alexander Medvednikov
733ac05bbd roadmap: c2v, autofree 2023-03-13 14:51:58 +01:00
Felipe Pena
d00237f02c cgen: fix code generated to option fn (fix #17604) (#17614) 2023-03-13 11:56:13 +02:00
Delyan Angelov
4ba7ad9446 tools: make v doctor more informative 2023-03-13 11:44:03 +02:00
yuyi
5cb1f8965a cgen: fix option struct init with reference option (#17617) 2023-03-13 09:58:45 +02:00
Thomas Mangin
0bd094292f v: add support for _qnx.c.v overriding _default.c.v (#17611) 2023-03-12 19:48:36 +02:00
Felipe Pena
3197ec1a41 v: add compile-time enum evaluation with $for item in MyEnum.fields { dump(item.value) dump(item.name) } (#17517) 2023-03-12 12:46:54 +02:00
Delyan Angelov
b2a71ecab2 pref: support v -e "println(2+5)" (#17605) 2023-03-12 00:42:36 +01:00
yuyi
95a9f0e29b ast, parser, fmt: fix fmt error of infix expr with comments (fix #17560) (#17583) 2023-03-12 01:07:13 +02:00
Thomas Mangin
8490ea318b readline: add more readline support to macos too (not simply os.get_raw_line based, but arrow key navigation, history etc too) (#17602) 2023-03-12 01:06:35 +02:00
ChAoS_UnItY
f02b423f80 builtin: string test refactor, string functions inlining (#17598) 2023-03-11 20:44:45 +02:00
Felipe Pena
ddcc22fe08 checker: fix parenexpr checking on assignment (#17593) 2023-03-11 14:56:47 +02:00
Alexander Medvednikov
dc24df9510 cbuilder: change order of functions to improve readability 2023-03-11 14:19:18 +03:00
yuyi
6e4dc82f28 sync: fix error of empty struct channel (fix #17556) (#17597) 2023-03-11 12:02:51 +02:00
Felipe Pena
a98376025e checker: fix missing re-check of recursive generic function (fix #16962) (#17592) 2023-03-11 11:57:41 +02:00
Swastik Baranwal
48a03a4874 checker: check wrapped Option types before comparison (#17590) 2023-03-11 11:16:12 +02:00
yuyi
b691e1e24a checker: check struct embed required field (#17595) 2023-03-11 11:12:26 +02:00
Petr Makhnev
0370116562 readme: add section about editor plugins and IntelliSense (#17596) 2023-03-11 11:00:10 +02:00
ChAoS_UnItY
9fa49da9d5 builtin: add rsplit functions (#17577) 2023-03-11 00:07:02 +01:00
Felipe Pena
ee4150f213 v: add a $Option comp-time type, to enable: $for f in Test.fields { $if f.typ is $Option { } } (#17546) 2023-03-10 12:17:25 +02:00
yuyi
09c9cbcef9 cgen: fix assign option value using propagate option (#17578) 2023-03-10 11:30:46 +02:00
yuyi
038fa6c8ab checker: remove warning of casting same reference type (#17579) 2023-03-10 11:07:09 +02:00
jmdyck
368604f9a5 docs: fix some minor mistakes (#17582) 2023-03-10 11:04:14 +02:00
Felipe Pena
23e385ee8a json: fix json decode/encode with option type (#17393) 2023-03-10 10:49:26 +02:00
yuyi
b42a3f43a5 crypto, math: change option to result (#17580) 2023-03-10 10:31:05 +02:00
Felipe Pena
32d09544d7 cgen, checker: fix dump() to return option values (#17563) 2023-03-09 20:29:25 +02:00
yuyi
71c3b66ecf datatypes: fix linked list of map (fix #17570) (#17573) 2023-03-09 14:26:01 +01:00
Felipe Pena
d353dd6e8a cgen: fix selector accessing field (#17567) 2023-03-09 14:24:43 +01:00
yuyi
737e7f6410 cgen: fix generic array of alias (#17571) 2023-03-09 13:57:14 +01:00
Felipe Pena
638805be63 cgen: fix code for unwrap option on print (#17545) 2023-03-08 20:55:19 +01:00
Felipe Pena
785546f277 json2: fix decode result with option fields (#17561) 2023-03-08 20:54:28 +01:00
Felipe Pena
b19052949f cgen: fix array initialization with options (#17562) 2023-03-08 20:54:00 +01:00
Felipe Pena
a0b3379d4a cgen: fix fn option-only return print (#17547) 2023-03-08 20:53:23 +01:00
Felipe Pena
e253256c30 cgen: fix option unwrap on assignment (#17551) 2023-03-08 20:52:24 +01:00
ChAoS_UnItY
ae6a48c0e3 all: rename it to index in array inits (#17543) 2023-03-08 20:51:45 +01:00
Felipe Pena
2597efa7f6 cgen: fix struct initialization with option value (#17539) 2023-03-07 23:53:56 +03:00
Felipe Pena
b4f0bb247d cgen: fix default initialization of option array with none values (#17536) 2023-03-07 23:53:07 +03:00
yuyi
b6c4e88462 checker: check error of casting to interface (fix #17522) (#17531) 2023-03-07 23:49:53 +03:00
Felipe Pena
b85f71d00f cgen: fix default init value for an array of option (#17538) 2023-03-07 20:04:16 +02:00
Felipe Pena
792b822091 cgen: fix dump(option_value) inside a generic function (#17537) 2023-03-07 18:13:19 +02:00
Felipe Pena
32751440b6 checker: fix missing check for none type on or block on non-option (#17529) 2023-03-07 18:11:03 +02:00
Felipe Pena
68cab00ded cgen: fix or-block with return void statement (#17527) 2023-03-07 15:01:46 +01:00
Felipe Pena
9826310882 cgen: fix struct initialization for nested option struct (fix #17524) (#17525) 2023-03-07 09:30:45 +01:00
Felipe Pena
1e416de627 checker: fix const init with comptime (#17528) 2023-03-07 09:15:46 +01:00
Ikko Eltociear Ashimine
784592af83 os: fix typo in os.v (#17519) 2023-03-07 08:30:37 +01:00
ChAoS_UnItY
6e670ec908 v: support interface field compile time reflection (#17503) 2023-03-07 08:52:40 +02:00
Alexander Medvednikov
d7a418fbb5 pref: no-skip-unused 2023-03-06 14:13:29 +01:00
yuyi
65a627d72b checker: allow aa := AA{}, when AA has an option field, that is a struct, that has a [required] tag on its fields (#17516) 2023-03-06 10:16:05 +02:00
Wertzui123
77b6bc1c1a net.websocket: fix a typo (allready -> already) (#17512) 2023-03-06 10:05:17 +02:00
Felipe Pena
7de3485bd2 cgen: fix multi return with option type (#17489) 2023-03-05 11:41:19 +01:00
Petr Makhnev
c1f249af6c test: handle compilation errors when running tests specially in the teamcity runner (#17511) 2023-03-05 10:14:23 +02:00
Petr Makhnev
1a48d08d7a cgen: add calls to all typeof functions for interfaces and sum-types (#17490) 2023-03-04 14:59:00 +02:00
Tim Marston
3f8821b8d8 cgen: unwrap and c-mangle field selectors in or blocks (#17495) 2023-03-04 11:52:08 +02:00
yuyi
6944d54257 parser, cgen: fix option variable error (fix #17460) (#17479) 2023-03-04 11:47:49 +02:00
yuyi
30c205ef2c cgen: fix printing map reference value (#17496) 2023-03-04 11:35:38 +02:00
l-m
6f7192359a wasm: bug fixes and memory based changes (#17497) 2023-03-04 11:24:33 +02:00
Felipe Pena
72cbca9653 checker: fix and improve return stmt error messages (#17477) 2023-03-04 09:32:55 +02:00
Felipe Pena
c5832379e7 checker, cgen, parser: fix Option/Result error messages (capitalized) (#17486) 2023-03-04 09:02:57 +03:00
Alexander Medvednikov
0ba0fb256f checker: check the type of SizeOf 2023-03-03 18:45:18 +01:00
Petr Makhnev
3c23a7ebba roadmap: tooling and web section for 1.0 (#17488) 2023-03-03 15:34:37 +01:00
Alexander Medvednikov
7876593eaf roadmap: 1.0 2023-03-03 14:58:49 +01:00
walking devel
5454562d2c checker, parser, orm: remove redundant & for sum type value arguments to functions with expr &ast.Expr parameters (#17482) 2023-03-03 14:35:12 +02:00
l-m
9c9adb125b doc: ignore builtin/wasm (#17480) 2023-03-03 12:35:21 +02:00
walking devel
5e2ff246c8 cgen: pass sum type values automatically by reference too, when functions require that (#17476) 2023-03-03 09:11:15 +02:00
Felipe Pena
904f984367 checker: fix or-block expected type checking (#17469) 2023-03-03 08:30:44 +02:00
Wertzui123
e8dbcd96bd readme: minor improvements (#17474) 2023-03-03 08:28:07 +02:00
yuyi
17000ef7b6 checker: check option fn returning error (fix #17423) (#17438) 2023-03-02 15:49:50 +02:00
Felipe Pena
8f7c35552d fmt: fix formatting for $compile_warn (#17450) 2023-03-02 15:40:53 +02:00
Delyan Angelov
9fc2860074 checker: fix compiler panic for for k, mut val in app.field[x].values { (#17468) 2023-03-02 15:40:14 +02:00
Samuel Šulovský
7497d8457f docs: fix incorrect struct literal and interface smart cast errors (#17457) 2023-03-02 13:31:12 +02:00
Delyan Angelov
e2daa84a33 ci: add windows and macos jobs for checking the wasm backend too (#17451) 2023-03-01 21:53:03 +02:00
l-m
cdc0159c6e wasm: update the compile flags in binaryen.c.v to assist darwin (#17449) 2023-03-01 14:21:08 +02:00
Felipe Pena
bba7cfee0b checker: check or-block used on non-option value (#17444) 2023-03-01 02:08:18 +02:00
walking devel
3682a9cf88 orm: allow use of mut db orm.Connection (#17439) 2023-03-01 00:49:30 +02:00
Felipe Pena
5f4b34ef12 eval: add host API, for passing and receiving values, to/from code, ran by the eval.Eval instances (#17426) 2023-03-01 00:42:19 +02:00
Haren S
acfd21e4e0 os: add #include <sys/types.h> to debugger_darwin.c.v, to fix bootstrapping on macOS <= 11 (#17446) 2023-03-01 00:06:12 +02:00
l-m
0625caad56 wasm: add a webassembly compiler backend, based on using binaryen (#17368) 2023-02-28 23:58:53 +02:00
yuyi
b9a8a21094 cgen: fix nested option struct init (fix #17415) (#17425) 2023-02-28 14:02:17 +02:00
Alexander Medvednikov
ebeb652348 readme: 4 ways to do memory management 2023-02-28 09:58:52 +01:00
Alexander Medvednikov
d5ad96f876 readme: minor fixes 2023-02-28 09:55:57 +01:00
walking devel
b7b6c2368e orm: allow using connections, that were explicitly casted to orm.Connection too (#17427) 2023-02-27 23:54:03 +02:00
Petr Makhnev
864e1994b0 vlib/time: format table for custom_format() (#17428)
* vlib/time: format table for `custom_format()`

* small fix

* small fix
2023-02-27 21:48:05 +02:00
Delyan Angelov
607649b44d builder: add small diagnostic and instructions for when the C cross compiler for linux->windows is not installed. 2023-02-27 16:59:56 +02:00
Delyan Angelov
91e0f7a3af tools/fast: add 2023.html link to the header, used by fast.v 2023-02-27 11:40:22 +02:00
paul-elesin
15cb18cbd2 os: make hostname and loginname functions return Result (#17414) 2023-02-27 05:21:23 +03:00
Delyan Angelov
9c511e03f6 tools: remove import v.pref, just for pref.vexe_path(), to compile tools faster (#17411) 2023-02-26 07:56:14 +02:00
yuyi
45d4849b0f checker: fix returning match expr with custom error (#17413) 2023-02-26 07:54:53 +02:00
Delyan Angelov
00aecf92e7 tools: make v self compile with tcc on Apple M1, since it is faster, and tcc now can handle it (#17409) 2023-02-26 01:26:33 +02:00
Delyan Angelov
4c13a4c22c ci: make websocket_test.v more robust (wait till the websocket server are open for connections, instead of relying on fixed time.sleep delays, which are not enough on the CI) 2023-02-25 19:39:14 +02:00
Delyan Angelov
524c500146 cgen: add requires to c_reserved, so that V generated code, can be compiled with -cc g++-11 -no-std -cflags -std=c++20 as well (#17404) 2023-02-25 16:50:48 +02:00
Delyan Angelov
cf47a5f978 ci: fix websocket_test.v after a7ae3bf 2023-02-25 14:46:31 +02:00
Felipe Pena
12ec0e9fe1 cgen: support option pointer values - ?&Type (#17397) 2023-02-25 14:44:41 +02:00
Petr Makhnev
51bb8cda15 test: fix teamcity runner message escapes (#17405) 2023-02-25 14:39:09 +02:00
Delyan Angelov
a7ae3bfa78 ci: fix all ports for the servers started in websocket_test.v 2023-02-25 14:36:54 +02:00
Delyan Angelov
e7bf33b206 ci: replace node-version: 12.x with node-version: 16 too 2023-02-25 14:29:00 +02:00
Delyan Angelov
2327f0781b ci: replace actions/setup-node@v1 with actions/setup-node@v3 2023-02-25 14:25:58 +02:00
Delyan Angelov
85b81ea9bb thirdparty: fix compilation of thirdparty/stb_image/stb_image.h with latest tcc on macos 2023-02-25 13:03:46 +02:00
Felipe Pena
9a8f3025f5 cgen: implement option fixed array (#17400) 2023-02-24 19:25:31 +02:00
yuyi
2836544978 cgen: minor cleanup of leftover comments in expr() (#17390) 2023-02-24 11:03:07 +02:00
Felipe Pena
6b20bddd15 cgen, json2: fix auto str option type generator, and json2 option type handling (#17388) 2023-02-24 10:54:45 +02:00
Alexander Medvednikov
94ce753df3 Update LICENSE 2023-02-24 04:37:43 +03:00
yuyi
acd903484d parser: fix channel pop with or expression: ch := <-self.item or { return none } (#17392) 2023-02-23 16:45:15 +02:00
Felipe Pena
248e9538ca parser: check for anonymous function param redefinitions (#17382) 2023-02-23 16:34:42 +02:00
Artem Yurchenko
d3870a0c7e README: update gg/sokol Ubuntu dependencies (add libgl-dev) (#17385) 2023-02-22 22:01:43 +02:00
Felipe Pena
2879afadd4 cgen, checker: fix none checking (#17364) 2023-02-22 16:13:02 +02:00
Swastik Baranwal
c173104295 cgen: add & before ptr arr elements (#17379) 2023-02-22 14:10:07 +02:00
Felipe Pena
6682911bc3 cgen: fix print fn + cycle const error message (#17355) 2023-02-22 13:38:08 +02:00
Delyan Angelov
b1ed1d3b32 ci: upgrade to actions/checkout@v3 to avoid deprecation warnings in the CI about that action using Node.js 12 2023-02-21 13:40:24 +02:00
Delyan Angelov
4a81272914 ci: upgrade sdl_ci.yml and native_backend_tests_ci.yml, to ubuntu-20.04, to avoid ci failures, due to the brownout period, for the deprecated ubuntu-18.04 2023-02-21 13:35:35 +02:00
Delyan Angelov
612ac69486 ci: fix bootstrapping on macos/freebsd etc 2023-02-21 12:30:35 +02:00
Felipe Pena
82c4338b76 os: move pub fn debugger_present() bool{ to platform-specific files (better ptrace portability handling) (#17373) 2023-02-21 10:55:03 +02:00
R cqls
cd00beb099 gg: add toggle_fullscreen and is_fullscreen (#17371) 2023-02-20 21:58:04 +02:00
Sanath Kumar U
269462425a tools: prevent v init from overwriting an already existing src/main.v file (fix #17362) (#17363) 2023-02-20 12:54:38 +02:00
Felipe Pena
cb976c7e17 os: fix the declaration of C.ptrace (the 4th parameter is a pointer, not an integer) (#17366) 2023-02-20 12:29:49 +02:00
yuyi
fcef8c98ee cgen: fix map of array initialisation, with len and no default (fix #17358) (#17367) 2023-02-20 12:26:48 +02:00
Swastik Baranwal
e9a3817aed checker: disallow enum initalization (#17361) 2023-02-19 22:22:07 +01:00
JalonSolov
79b2c34f97 arrays: replace C.memcpy with vmemcpy calls, to make v -shared -Wimpure-v vlib/arrays/ pass (#17357) 2023-02-19 19:01:18 +02:00
Felipe Pena
8a1e90fff1 checker: allow none to be casted to all option types, including aliases (#17348) 2023-02-19 18:56:14 +02:00
Felipe Pena
ce1978ecde parser: disallow defining methods on option receivers - fn (x ?Type) method() { (#17351) 2023-02-19 15:00:29 +02:00
Petr Makhnev
d971d93066 vccheck-md: add play and play-test command (#17350) 2023-02-18 20:55:10 +02:00
yuyi
93a3f5ff7d builtin, cgen: fix array of struct with map field initialize (fix #17325) (#17340) 2023-02-18 20:34:15 +02:00
Artem Yurchenko
8011121d43 README: fix twitter badge (fix #17166) (#17339) 2023-02-18 14:33:30 +02:00
Artem Yurchenko
d616fb0a43 docs: add a Disabling the formatting locally section, about // vfmt off and // vfmt on (#17341) 2023-02-18 14:26:28 +02:00
Felipe Pena
2879c5110c cgen, check, parser: implement first-class option type (#17017) 2023-02-18 11:45:01 +02:00
Felipe Pena
e066d1d3df cgen: fix missing aggregate rec_type (#17335) 2023-02-16 16:36:16 +01:00
Artem Yurchenko
936bced29e readme: improve the sections about the installation of dependencies (#17336) 2023-02-16 12:25:51 +02:00
Felipe Pena
7f5cba1a38 cgen: add comptime field.name checking (#17318) 2023-02-16 11:46:27 +02:00
Ahmad Yasser
cad2cd5583 docs: fix typos using codespell (#17332) 2023-02-16 11:43:39 +02:00
walking devel
580dbc3f0e orm: allow inserting empty objects with db.sqlite (SQLite uses a slightly different SQL dialect) (#17334) 2023-02-16 11:34:16 +02:00
yuyi
289993ad7f checker: fix printing address of integer variable (#17327) 2023-02-15 20:05:26 +02:00
Ikko Eltociear Ashimine
2382549df3 math: fix typo in factorial.v (#17322) 2023-02-15 19:57:37 +02:00
walking devel
5d4c9dc9fc checker: allow using struct field as ORM limit and offset. (#17330) 2023-02-15 19:47:35 +02:00
zakuro
f5423ed26b checker: fix warning of unnnecessary default none value for option struct fields (#17305) 2023-02-15 11:42:00 +02:00
Felipe Pena
039c9b2550 cgen, checker: fix comptimeselector resolution + if comptime branching improvement + comptimeselector cleanup (#17302) 2023-02-15 11:40:11 +02:00
yuyi
5a8c433548 cgen: fix printing a reference to a function (#17307) 2023-02-15 11:27:21 +02:00
irishgreencitrus
4691c5d637 doc: add a section documenting #preinclude (#17304) 2023-02-15 11:25:13 +02:00
yuyi
d0a873ca02 checker: fix printing the address of a struct value with println('${&value:p}') (#17321) 2023-02-15 11:20:25 +02:00
yuyi
b6ecd634e3 tests: change option to result in vscript_using_generics_in_os.vsh (#17306) 2023-02-14 13:01:35 +02:00
Delyan Angelov
b13f7118ab os,term: fix C.tcsetattr declaration (add missing int return type) 2023-02-13 15:16:23 +02:00
starryskye
2d3508c872 net.websocket: call close event (#17300) 2023-02-13 14:28:41 +02:00
Felipe Pena
16344cfc28 checker: fix sumtype cast of comptime var (#17287) 2023-02-13 13:24:36 +01:00
Felipe Pena
fbcb1f3711 checker: disallow &nil (#17283) 2023-02-13 13:24:11 +01:00
Felipe Pena
04e00a46d4 cgen, checker: allow array decompose on non-variadic func call (e.g call(...arr)) (#17284) 2023-02-13 13:13:52 +02:00
Makhnev Petr
d907ceb50f docs: format with IDEA formatter other .md files (#17293) 2023-02-13 12:49:13 +02:00
Makhnev Petr
c8c70de87d docs: unify format of notes (#17294) 2023-02-13 10:29:02 +02:00
zakuro
e7fcf66095 tests: add more tests for struct option fields in vlib/v/tests/option_test.v (#17297) 2023-02-13 10:02:47 +02:00
Makhnev Petr
65d218e005 docs: format with IDEA formatter (#17291) 2023-02-12 17:25:04 +02:00
Felipe Pena
eb7e1b4712 cgen: fix cast with comptime var (#17286) 2023-02-12 07:54:09 +01:00
yuyi
6883561d6d cgen: fix c_fn_name() for mongo module (#17282) 2023-02-11 20:33:41 +02:00
yuyi
90591eb813 checker: check nested struct field with required attr (fix #10913) (#17277) 2023-02-11 11:22:31 +02:00
walking devel
03be525c82 orm: allow using reference objects in ORM insert. (#17279) 2023-02-11 10:02:55 +02:00
MatejMagat305
ac381f5e5b docs: add git to the list of installed prerequisites for V on Termux (#17276) 2023-02-10 17:02:02 +02:00
walking devel
0a742a6690 docs: add new line before tables (#17272) 2023-02-10 11:53:38 +02:00
MatejMagat305
c003bfd5d4 docs: add make to the list of installed prerequisites for V on Termux (#17269) 2023-02-10 01:00:33 +02:00
yuyi
7cfbc1cc5f checker: fix generic array of sumtype push operation (#17268) 2023-02-10 00:27:07 +02:00
Felipe Pena
3aecd01d05 tests: add empty_struct_compare_test.v too (#17270) 2023-02-10 00:26:41 +02:00
Riccardo
ba9a9fdc2a builder: fix bug for incorrectly detecting tcc as icc, when V was installed in a path containing icc (#17271) 2023-02-10 00:24:03 +02:00
MatejMagat305
dcb9c3beb3 cgen: support [spawn_stack: 131072] fn attribute, for controlling the max size of the stack, of the spawned threads (#17222) 2023-02-09 15:57:53 +02:00
yuyi
19ba7c5ceb parser: fix fn attrs with anon struct param (#17266) 2023-02-09 14:10:28 +02:00
fanlia
4c33a92aac examples: fix missing products table in v run examples/vweb_fullstack/ (#17253) 2023-02-09 12:03:23 +02:00
yuyi
34efc9c427 checker: fix returning if expr with custom error (#17265) 2023-02-09 11:45:46 +02:00
Felipe Pena
47e8d967e6 v.reflection: add type symbol info metadata (#17188) 2023-02-08 21:30:44 +02:00
Felipe Pena
fbfdab9e2d cgen: remove unused generated func (#17258) 2023-02-08 21:27:24 +02:00
ChAoS_UnItY
404a9aa442 v: forbid function parameter names, shadowing imported module names (#17210) 2023-02-08 20:37:04 +02:00
Delyan Angelov
c16549b6fd ci: fix VLS compilation after 36dc7fa 2023-02-08 14:04:03 +02:00
Delyan Angelov
6b0b7a9e4f cgen: fix compilation of vlang/sdl examples 2023-02-08 13:27:59 +02:00
Delyan Angelov
36dc7faf2c net.openssl: add manual .str() methods for C.SSL and C.SSL_CTX, fix a bug in the V auto str generation as well. 2023-02-08 13:14:12 +02:00
Delyan Angelov
522a9f5908 net.openssl: add V side declaration for C.SSL_CTX too (fix auto .str() method generation for V structs containing references to C.SSL_CTX) 2023-02-08 12:33:21 +02:00
yuyi
6136b62220 cgen: fix method calls to nonarray methods, named first, last or repeat (#17252) 2023-02-08 10:45:17 +02:00
Mehmet Ali
0b17865c3d examples: use -Wl,-rpath=. instead of LD_LIBRARY_PATH=. in the call_v_from_c example (#17244) 2023-02-08 09:44:10 +02:00
Delyan Angelov
9794a239b1 sokol.sgl: add wrapper for scissor_rectf too 2023-02-07 12:53:59 +02:00
yuyi
a173f2964e cgen: minor cleanup in stmt() (#17240) 2023-02-07 09:17:10 +02:00
yuyi
223c752460 cgen: fix for in mut array with infix expr (#17233) 2023-02-07 00:10:07 +02:00
MatejMagat305
954843c486 os: fix default result of os.temp_dir() for termux (#17237) 2023-02-07 00:07:35 +02:00
yuyi
e76e93d230 ast: add comments for ast.AssertStmt and ast.IfGuardExpr (#17235) 2023-02-06 16:39:03 +02:00
yuyi
7090e905f7 checker: fix array filter of fn mut argument (#17231) 2023-02-06 16:37:37 +02:00
Mehmet Ali
791ef4b4a6 gg: fix gg.scissor_rect behavior on Android (#17229) 2023-02-06 12:26:20 +02:00
yuyi
242d6fa1ff checker: disallow for mut letter in 'abc' { (#17234) 2023-02-06 11:58:03 +02:00
yuyi
858ce4e35d cgen: correct comments for expr_with_tmp_var() (#17227) 2023-02-05 14:16:29 +02:00
yuyi
fc65de9bba checker: check sumtype in unknown type (#17225) 2023-02-05 12:02:30 +01:00
yuyi
c40e25b028 cgen: fix assigning option of struct fntype field (#17224) 2023-02-05 09:13:19 +02:00
Delyan Angelov
d349648cda vfmt: fix typename DecompressParams -> DezParams in function parameters, on import compress as z (fix #17216) 2023-02-05 00:25:14 +02:00
yuyi
e8ca2e62a7 checker: fix if guard with struct option fntype field (#17220) 2023-02-04 11:38:07 +02:00
Makhnev Petr
804065a0fa docs: remove note illustrating shadowng of import name, due to 0b7a1cd (#17208) 2023-02-03 09:17:56 +02:00
ChAoS_UnItY
0b7a1cd7ce v: forbid local variable names, shadowing imported module names (#17197) 2023-02-03 09:09:41 +02:00
Tim Marston
603469b856 cgen: don't voidptr cast option/result functions (fix #17204) (#17207) 2023-02-03 08:50:20 +02:00
Swastik Baranwal
6d63b27c26 checker: disallow function calls returning void, in () expressions, in assignments (#17205) 2023-02-03 08:47:52 +02:00
walking devel
8cdc554c63 net.html: fix panic in html.parse() called with empty string, remove replacement of \n in the original content (#17206) 2023-02-03 00:32:03 +02:00
Delyan Angelov
a8102f14be make: use git clone --filter=blob:none for vc/ and thirdparty/tcc/ , which minimises the amount of transferred data (especially for doing v up after a few weeks/months) 2023-02-02 18:33:51 +02:00
yuyi
b5b1efbb7b cgen: fix sumtype as cast with calling twice (#17196) 2023-02-02 13:57:37 +02:00
Delyan Angelov
6572d597f9 Revert "cgen: fix sumtype as cast with calling twice (fix #17156) (#17183)"
This reverts commit 90ae3c82c9.
2023-02-02 10:49:15 +02:00
yuyi
90ae3c82c9 cgen: fix sumtype as cast with calling twice (fix #17156) (#17183) 2023-02-02 09:31:11 +02:00
Delyan Angelov
988aed0353 ci: fix broken tests after 322eb81 2023-02-01 23:30:48 +02:00
Alexander Medvednikov
322eb8197d checker: make null warning an error 2023-02-01 18:01:55 +01:00
MatejMagat305
e70848a98b dl: add more dlopen flags (#17184) 2023-02-01 18:32:35 +02:00
Hitalo Souza
ed58b95a9d json2: encode array of all and verify sum type (#17051) 2023-02-01 15:52:58 +01:00
Dennis T Kaplan
9809427f40 README: add Void Linux installation instructions (#17176) 2023-02-01 11:48:44 +02:00
Christopher Fore
2029d1830f tools: remove cmd/tools/modules/vhelp/ & add print to v share (#17178) 2023-02-01 11:18:23 +02:00
walking devel
02fc58d124 orm: add type checker for where (#17179) 2023-02-01 10:53:34 +02:00
Christopher Fore
10261c427f tools: add v share file.v (#17172) 2023-01-31 20:36:17 +02:00
Tim Marston
26b9464f51 gg: setup ctx.window.user_data and ctx.user_data on ctx.run(), instead of in gg.new_context, to allow for embedding gg.Context in ui (#17169) 2023-01-31 18:22:20 +02:00
Delyan Angelov
a932a8b1ea net.http: make the errors that parse_status_line returns more informative to make diagnosing problems easier 2023-01-31 15:26:08 +02:00
Alexander Medvednikov
8009bc3a98 changelog: more 0.3.3 features 2023-01-31 14:17:48 +01:00
Christopher Fore
b3d742d13a v.help: reorganise the folder layout of the v help topic text files (#17155) 2023-01-31 12:04:01 +02:00
walking devel
d563739264 checker: add type checking for ORM limit, offset, and order by. (#17095) 2023-01-31 10:22:02 +02:00
Swastik Baranwal
b487c9d38e parser: add more precise errors, for fn (p Point) += (q Point) Point { (#17167) 2023-01-31 09:36:33 +02:00
JalonSolov
0d04104112 docs: change one more Optional to Option (#17170) 2023-01-31 09:32:11 +02:00
Ulises Jeremias Cornejo Fandos
40ec2a292e vlib: add a new dl.loader module, to simplify dynamic library loading, when the DLLs may be in multiple customisable locations (#17161) 2023-01-31 09:27:48 +02:00
Alexander Medvednikov
2d51379f00 changelog: more 0.3.3 features 2023-01-30 21:44:22 +01:00
Ahmad Yasser
6b20c57246 docs,sync: separate example code blocks with a newline (#17165) 2023-01-30 21:25:33 +02:00
Delyan Angelov
5abca37ff7 parser: add a temporary exception for C.statvfs as well (same name reused for function *and* struct) 2023-01-30 21:11:59 +02:00
Alexander Medvednikov
d1f57ead71 V 0.3.3 2023-01-30 18:20:51 +01:00
Delyan Angelov
62f7e56a18 v.vcache: fix a panic due to a race on creating folders in ~/.vmodules/cache/XY 2023-01-30 19:00:00 +02:00
Delyan Angelov
9c78e3c289 tools: fix v check-md . on windows too (skip thirdparty/ and the CHANGELOG) 2023-01-30 18:56:03 +02:00
Alexander Medvednikov
1470eb6fa4 gg: fix native image rendering with with/height=0 2023-01-30 16:06:18 +01:00
Delyan Angelov
38b02c908d thirdparty: update stb_image.h to its latest version v2.28 2023-01-30 13:06:09 +02:00
Felipe Pena
11f734296f checker: fix generic array clone (#17153) 2023-01-30 11:27:17 +02:00
walking devel
a489417484 orm: detect type mismatching on inserting an object (#17157) 2023-01-30 11:26:10 +02:00
l-m
bb512f782e checker, ast: add field promoted_type for InfixExpr, filled in by the checker, to save duplicate work in the backends (#17158) 2023-01-29 21:06:05 +02:00
walking devel
4747e70d9d orm: make last_id() return int, instead of orm.Primitive (fix #12110) (#17151) 2023-01-29 16:00:23 +02:00
Felipe Pena
e6a4f76f82 cgen: fix returing comptime if expressions within functions with an option result (#17154) 2023-01-29 15:59:13 +02:00
anusrnm
5cd01ea494 gzip: fix flag location in header (#17140) 2023-01-29 13:27:04 +02:00
Swastik Baranwal
7f5f69a78a checker: check option and result handling in as casts (#17133) 2023-01-29 12:28:14 +02:00
Felipe Pena
cb79e57c1a cgen: fix generated code for match bar()?.a { (matchexpr with call expr using propagation) (#17150) 2023-01-29 12:11:30 +02:00
walking devel
9a86456365 cgen: support string interpolation in ORM queries (#17141) 2023-01-29 01:27:34 +02:00
yuyi
d3e4058aec cgen: fix printing for mut v in arr (#17137) 2023-01-28 10:15:28 +02:00
Felipe Pena
b732dd6816 cgen: fix opt member eq operation (#17134) 2023-01-28 10:13:11 +02:00
walking devel
e064743c73 parser: recursively search undefined variables in the where parts of SQL statements (#17136) 2023-01-28 10:07:02 +02:00
Nahua
1d4fd53344 net.http: add documentation to http, method, server, and status (#17130) 2023-01-27 13:58:55 +02:00
MatejMagat305
fe157db0ce v: support an optional fn cleanup() { in each module, to complement the existing optional fn init() { (#17119) 2023-01-27 11:31:03 +02:00
walking devel
a9a04bba55 orm: support fn calls in where (#17127) 2023-01-26 22:36:30 +02:00
l-m
c14d15bd3d ast,checker,parser,cgen: [c:'sym'] rework; allow compiling code from .v files tagged with [translated] without needing -translated too (#17125) 2023-01-26 17:47:38 +02:00
Makhnev Petr
6365d9e070 checker: forbid var declaration in post statement of for loop (#17120) 2023-01-26 17:40:10 +02:00
Makhnev Petr
15c0a73740 checker: fixed error pointer for "redefinition of key iteration variable" and "redefinition of value iteration variable" errors (#17121) 2023-01-26 12:31:35 +02:00
Nahua
21b17fe234 io: add missing documentation and edit existing ones (#17105) 2023-01-25 22:03:20 +02:00
Felipe Pena
84b99ceeb2 vlib: add a v.reflection module for reflection done at runtime (#17072) 2023-01-25 22:01:22 +02:00
Swastik Baranwal
e32ed368ca ast, checker, parser: add enum type pos (#17112) 2023-01-25 21:59:28 +02:00
Keito Tobichi
6bb930591e examples: add more graphs examples, fix typo (#17113) 2023-01-25 21:58:44 +02:00
Delyan Angelov
86f8c55107 ast: improve the support for #flag comptime_known_define something (support #flag wasm32_emscripten etc) 2023-01-25 17:38:47 +02:00
Delyan Angelov
d2e5c721a0 net: allow more fine grained control over socket shutdowns 2023-01-25 12:34:39 +02:00
walking devel
b34c55ffd6 ast: fix TypeSymbol.is_primitive, add TypeSymbol.is_bool (#17106) 2023-01-25 08:38:59 +02:00
Makhnev Petr
0874376db0 builtin: fix wrong module name imported in vlib/builtin/linux_bare/old/.checks/linuxsys/linuxsys.v (#17102) 2023-01-24 22:19:30 +02:00
Makhnev Petr
17d65db828 builtin: add string.trim_indent()` method (#17099) 2023-01-24 21:41:25 +02:00
Makhnev Petr
5aad0db0f7 parser: improve error for prefix inc/dec statement --a/++mp["id"] (#17090) 2023-01-24 10:08:35 +02:00
Makhnev Petr
91799a1742 checker: add error for inc/dec for non lvalue (#17091) 2023-01-24 10:03:37 +02:00
Roy Ivy III
5cd074a49e builtin: improve multi-platform portability for string.split_into_lines() (#17078) 2023-01-24 10:02:25 +02:00
Hitalo Souza
0230395062 examples: update examples/js_dom_draw_bechmark_chart/README.md with a chart (#17084) 2023-01-24 02:07:13 +02:00
Nahua
da3ad2dca6 gx: add missing documentation or update existing ones for public functions (#17094) 2023-01-24 02:02:07 +02:00
walking devel
8b6fceb0a3 cgen: fix -autofree with arr[idx] or { default } (#17096) 2023-01-24 00:53:26 +02:00
MatejMagat305
16e2ade9ff docs: add termux to the list of known supported platforms (#17093) 2023-01-24 00:31:34 +02:00
Makhnev Petr
5dde4ce981 docs: improve the operator overload description (#17085) 2023-01-24 00:24:50 +02:00
Makhnev Petr
f4289cd302 docs: expand empty <a> tags (#17092) 2023-01-24 00:16:01 +02:00
Delyan Angelov
f667600cd5 docs: update count of reserved keywords to 44 after both 828ab47 and 3df231c were merged. 2023-01-23 11:50:20 +02:00
Makhnev Petr
828ab473c1 docs: add __global to keyword list (#17081) 2023-01-23 11:45:05 +02:00
MatejMagat305
6d223b9a26 builtin: add a map.reserve/1 method (#17052) 2023-01-23 11:07:25 +02:00
Makhnev Petr
3a9355d898 change or{} to or {} as most other places (#17082) 2023-01-23 11:05:34 +02:00
Makhnev Petr
3df231c466 doc: add spawn to keyword list (#17080) 2023-01-23 03:48:32 +03:00
yuyi
865c0ea8bd checker: check generic struct no_keys init (fix #17061) (#17067) 2023-01-22 19:11:12 +02:00
Thomas Peißl
3aeb6179b7 os: rework mv so it works with different partitions (add fallback to os.mv_by_cp + tests) (#17065) 2023-01-22 19:02:04 +02:00
yuyi
a929466130 checker: minor cleanup in infer_fn_generic_types() (#17068) 2023-01-22 15:02:08 +02:00
yuyi
b2dac566b0 checker: check fn call using 'none' as argument (#17070) 2023-01-22 14:58:34 +02:00
Wenqi Chen
ddf3909fed docs: improve the README for examples/call_v_from_c/ with instructions for macos (#17060) 2023-01-22 13:25:09 +02:00
Delyan Angelov
f69b994c73 os: properly document os.uname, for both nix and windows 2023-01-22 13:18:28 +02:00
Roy Ivy III
dd55365dee os: cleanup the output of os.uname() on windows (#17066)
* os: (WinOS) mimic current practices of `busybox` and `coreutils`

* os: trim any possible surounding whitespace
2023-01-22 11:59:42 +02:00
Delyan Angelov
0bafd237ee ast: fix const dependency order for consts initialised with ast.SelectorExpr (fix #15049) (#17064) 2023-01-22 09:34:46 +02:00
Hitalo Souza
0ac6ba9354 json2: encode sumtype (#17041) 2023-01-21 20:26:55 +02:00
Hitalo Souza
1d51f3109f json2: improve the performance of encode ~2x (#17050) 2023-01-21 10:45:38 +02:00
yuyi
630fb2af37 cgen: fix generic struct no_key init (#17059) 2023-01-21 10:42:15 +02:00
Hitalo Souza
1c6195c1b6 bench: jump to the top level functions in bench_json_vs_json2.v (#17054) 2023-01-21 10:40:12 +02:00
Hitalo Souza
9a43fa9668 bench: add more benches of json vs x.json2, separated by type (#17043) 2023-01-20 19:11:50 +02:00
yuyi
222eb86e6e tests: correct the test comment in generic_fn_with_alias_arg.vv (#17048) 2023-01-20 18:53:42 +02:00
Delyan Angelov
46e4317643 benchmark: adjust the documentation for Benchmark.measure 2023-01-20 17:22:49 +02:00
MatejMagat305
d2bde39347 v.cflags: use strings.Builder instead of concatenation for constructing flags (#17049) 2023-01-20 16:20:36 +02:00
Nahua
90dbf683d5 term: add missing documentation for all remaining public functions (#17044) 2023-01-20 11:07:28 +02:00
MatejMagat305
25f1b713aa crypto.pem: add Block.free() method (#17045) 2023-01-20 10:49:45 +02:00
phoebe
fed6524803 vlib: add a crypto.pem module (#17034) 2023-01-19 17:01:11 +02:00
Thomas Peißl
ba1b31700e os: add hint for mv_by_cp to mv (#17036) 2023-01-19 16:50:57 +02:00
John
4098612a87 rand: add full precision f32 and f64 random functions; fix f32/f64 multipliers (#16875) 2023-01-19 15:21:47 +02:00
Delyan Angelov
550cae931f bench: add bench_random_number_generation.v 2023-01-19 15:19:29 +02:00
Delyan Angelov
12f9e922bc ci: rename all github actions workflow files, that are related to CI (run on commits/PRs), to have a _ci.yml postfix 2023-01-19 14:38:33 +02:00
Delyan Angelov
c7a829e74f ci: split windows/linux/macos jobs from the single ci.yml to 3 separate .yml files
This split is needed, so failing jobs on macos/windows, could be restarted
independently from each other more easily, through the web interface on github.
2023-01-19 14:32:55 +02:00
Delyan Angelov
92c7e3f7ff checker: relax checks on operators done on aliases of primitives like int, u8, string etc.; add tests (#17029) 2023-01-19 11:45:56 +02:00
Delyan Angelov
269833b72c tools: move cmd/tools/vcreate.v and its test, to its own folder cmd/tools/vcreate/ (part 1) 2023-01-19 09:54:08 +02:00
Delyan Angelov
bee355eb65 all: cleanup sqlite.connect statements (do not leave strange test.db or vweb.sql artefacts around, after running common tests) 2023-01-19 09:45:07 +02:00
Minsoo
36834be2ad all: fix the remaining deprecated import sqlite statements (#17021) 2023-01-19 09:37:55 +02:00
Nahua
b69f9419f0 term: add missing documentation for all public functions in colors.v (#17033) 2023-01-19 09:09:09 +02:00
Minsoo
d850d3caba net.html: add get_tags_by_class_name (#17024) 2023-01-18 19:00:46 +02:00
yuyi
6688c0f3d7 checker: fix generic fn infering error with alias argument (#17026) 2023-01-18 18:59:02 +02:00
Hitalo Souza
525c5e237a x.json2: add json2.map_from(t T) (#16797) 2023-01-18 18:55:04 +02:00
Delyan Angelov
2c78078814 cleanup: fix old usages of os.write_file/2? to os.write_file/2! 2023-01-18 12:28:10 +02:00
yuyi
6a9688ce9d checker, cgen: fix for mut i in arr { i = i * i } (#17020) 2023-01-18 09:22:38 +02:00
Delyan Angelov
1cad788779 checker: add error for type Alias = map[string]Alias (fix #17008) (#17015) 2023-01-18 01:34:43 +02:00
yuyi
88dab8fc2d all: clean up multiple 'is' infix expr (#17005) 2023-01-17 20:27:09 +02:00
walking devel
2fb9bdce9a cgen, checker: add panic in ORM for invalid queries, when there are no or {} blocks, add type checking for the fkey attribute, add tests (#16977) 2023-01-17 20:21:10 +02:00
Nahua
93ee6d107a encoding.base32: add missing documentation for all public functions (#16998) 2023-01-17 19:46:43 +02:00
Felipe Pena
5dbdb211dc cgen: fix assignment from comptime var (#16999) 2023-01-17 19:39:19 +02:00
yuyi
a22dfe0ddf cgen: minor cleanup in dump_expr() (#17006) 2023-01-17 17:11:04 +02:00
Delyan Angelov
75d6cb9c3a checker: protect against unlimited recursion in Checker.ensure_generic_type_specify_type_names 2023-01-17 13:07:27 +02:00
yuyi
2034dcb4ed ast: fix const values defined in the wrong order (#17002) 2023-01-17 12:12:54 +02:00
yuyi
930e629d2e cgen: fix struct init with chan field (#17001) 2023-01-17 05:50:11 +01:00
Felipe Pena
1302dbf02f checker: fix for..in statement with ComptimeSelector (#16997) 2023-01-17 05:49:45 +01:00
yuyi
f57b16a843 all: clean up multiple !is infix expr (#16993) 2023-01-17 05:48:44 +01:00
Felipe Pena
f634c6e0a4 checker: fix postfix var checking break (#16984) 2023-01-17 05:47:51 +01:00
yuyi
21807f94a2 checker: check unsafe map index operation (#17000) 2023-01-17 05:47:16 +01:00
MatejMagat305
6bf6a40e0c crypto: add .free() and .reset() methods to reduce memory leaks with -autofree (#16992)
* Fix unsafe pointer

I was compile vab with '-prod' and it was needed  to fix and it is of course warning

* Add files via upload

* reduce memory  leak s sha512

* add method .free() and .reset() for some
2023-01-16 17:30:40 +02:00
MatejMagat305
92fd12c18a crypto.sha256: add .free() and .reset() methods to reduce memory leaks with -autofree (#16991) 2023-01-16 13:23:46 +02:00
yuyi
e5fb457b19 checker: fix map with reference value (#16990) 2023-01-16 11:45:22 +02:00
Hitalo Souza
55787ff78f json2: refactor, doc, perf, test, errors (#16986) 2023-01-15 22:52:48 +01:00
Alexander Medvednikov
7a9a82879b checker: use a notice for now 2023-01-15 22:38:31 +01:00
Alexander Medvednikov
aba7bcde85 checker: turn the pointer map notice into a warning and fix all code using it 2023-01-15 22:19:25 +01:00
Swastik Baranwal
e8108f21e0 checker: check option and result handling in type-casted aliases (#16988) 2023-01-15 23:09:30 +02:00
Nahua
5f30110e2c hash: document all public functions (#16987) 2023-01-15 22:37:09 +02:00
Hitalo Souza
7db7951bd0 x.json2: fix: #16975 (#16983)
* fix: #16975

* test

* Update vlib/x/json2/json2.v

Co-authored-by: Delyan Angelov <delian66@gmail.com>

* minor refactor

Co-authored-by: Delyan Angelov <delian66@gmail.com>
2023-01-15 22:09:02 +02:00
Delyan Angelov
bfb47005c8 net.openssl, net.mbedtls: add support for -d trace_ssl, for easier tracing of binary protocol problems to https servers 2023-01-15 16:06:46 +02:00
Delyan Angelov
7f3531077d examples: improve the output of the websocket examples 2023-01-15 14:54:51 +02:00
Delyan Angelov
634f596d27 git: remove cruft 2023-01-15 13:54:26 +02:00
Delyan Angelov
d4320863fe net: fix compilation with -d trace_tcp_data_write and -d trace_tcp_data_read; add .hex() dumping too for easier diagnosing of binary protocol level problems 2023-01-15 13:25:23 +02:00
Hitalo Souza
28cbaf66b8 json2: refactoring and fixes (#16893) 2023-01-15 12:30:33 +02:00
Felipe Pena
4d2c767dcb checker: fix for $if field.unaliased_typ is $Int { (#16982) 2023-01-15 12:27:08 +02:00
Delyan Angelov
e8e1df6df9 tests: make VTEST_ONLY=panic ./v vlib/v/slow_tests/inout/compiler_test.v more useful as a filter 2023-01-15 11:38:37 +02:00
Delyan Angelov
2b4c60d07f tests: sort the .vv files in vlib/v/slow_tests/inout/compiler_test.v, before testing them, to have more predictable output 2023-01-15 11:34:10 +02:00
Alexander Medvednikov
877a1e511a checker: require unsafe for accessing a pointer map value 2023-01-15 02:47:13 +01:00
Hitalo Souza
b25c9e8bbf examples: minor change after #16948 (#16965) 2023-01-15 02:39:51 +01:00
yuyi
7fd9b62b34 parser: fix type alias of fn with mut argument (#16974) 2023-01-14 21:38:46 +02:00
Hitalo Souza
199db81b23 json2: refactor after #16951 (#16976) 2023-01-14 21:30:29 +02:00
Felipe Pena
dbfb9c3a90 cgen, checker: var type checking at compile-time (#16951) 2023-01-14 16:20:12 +02:00
Delyan Angelov
b19db3a207 ci,term: add a term.set_tab_title/1 shim for windows too (for now just calling term.set_terminal_title/1) 2023-01-14 15:10:12 +02:00
Felipe Pena
71e8fc8b38 checker: fix comptime if branch checking (#16938) 2023-01-14 15:06:38 +02:00
Felipe Pena
80cd9f820a checker,cgen: allow ?.str() on compile-time fields var (#16969) 2023-01-14 15:04:13 +02:00
Delyan Angelov
6adafbb6ea term: add a separate term.set_tab_title/1 API for controling the current tab title in emulators like Konsole, that support many tabs 2023-01-14 12:00:39 +02:00
l-m
ca000292f1 cgen,js: support [autostr: allowrecurse] attribute, for allowing deep printing of data structures with pointer fields (trees, instead of graphs with cycles) (#16973) 2023-01-14 11:30:39 +02:00
Delyan Angelov
7e05545a62 ci: v install pcre too, since it is now needed for gitly 2023-01-14 11:22:25 +02:00
Delyan Angelov
7c571c0945 term: fix set_terminal_title on nix 2023-01-14 11:08:49 +02:00
yuyi
fd07f7df69 cgen: fix printing struct having fields of arrays of anonymous structs (#16953) 2023-01-14 00:41:31 +02:00
Felipe Pena
41b9e513ca parser: add a better error message, for multiple attributes, used on the same struct field (#16954) 2023-01-13 23:27:46 +02:00
Ahmad Yasser
3832f076c5 docs: fix all db.pg docs being italic in html format (#16971) 2023-01-13 23:25:24 +02:00
Swastik Baranwal
89aa695fba checker: disallow non ptr struct values to voidptr fields (#16958) 2023-01-13 17:05:18 +02:00
yuyi
64558df764 vlib: move the mysql/sqlite/pg/mssql modules under vlib/db (#16820) 2023-01-13 17:02:32 +02:00
walking devel
2d8f160ef1 checker: replace the go keyword in error messages with spawn (#16960) 2023-01-13 13:23:51 +02:00
zakuro
c766ce4fe5 fmt: fix removal of selective imported types, used as array elements (#16963) 2023-01-13 09:30:28 +02:00
Felipe Pena
ba091a36dd checker: fix unreachable code checking for sql ORM blocks (#16948) 2023-01-12 15:36:44 +02:00
Delyan Angelov
33191e4538 ci,pg,net.openssl: fix pkgconfig paths for macos-12 2023-01-12 15:22:08 +02:00
yuyi
148d57827c parser, fmt: fix fmt in struct declarations with a fields, declared to be arrays of anonymous structs (fix #16947) (#16952) 2023-01-12 13:21:29 +02:00
Delyan Angelov
9e78724a41 ci: use brew install libpq for installing the postgresql development libraries on macos 2023-01-12 11:54:55 +02:00
Alexander Medvednikov
22666f4f73 ci: build vpm on macos 2023-01-12 09:54:52 +03:00
yuyi
329b9f1a6a parser, fmt: fix fmt error in $tmpl(path) (#16949) 2023-01-12 06:03:38 +01:00
Delyan Angelov
49a434e11f pg: fix compilation on macs with clang (libpq installed through brew) 2023-01-12 02:21:32 +02:00
Delyan Angelov
131086b647 ci: workaround for $if prod { not working properly with msvc 2023-01-12 00:02:27 +02:00
Delyan Angelov
00cef70220 ci: fix -prod compilation of sokol apps 2023-01-11 22:37:41 +02:00
Delyan Angelov
60f4654bbe tools: make fast.v log all executed commands 2023-01-11 21:05:45 +02:00
Delyan Angelov
d9339b09d6 sokol.memory: fix message logs on Android 2023-01-11 16:37:20 +02:00
yuyi
3f8aa77990 parser: fix tmpl using variable or const path argument (fix #16941) (#16943) 2023-01-11 13:31:48 +02:00
walking devel
3e9b06031c doc: fix v wrapper command mention (#16944) 2023-01-11 13:31:00 +02:00
Swastik Baranwal
b872487d82 cgen: allow ORM to work with DB aliases (#16939) 2023-01-11 11:58:55 +02:00
Delyan Angelov
e854051c1f thirdparty: update all sokol and fontstash headers with their upstream versions (#16940) 2023-01-11 11:29:38 +02:00
Hitalo Souza
d1306ffcf5 checker,json2: relax checking of x.enum = integer at comptime; refactor json2 to clean it up (#16926) 2023-01-11 10:18:45 +02:00
Felipe Pena
09f48455c5 checker,cgen: allow method.name checking in comptime (#16931) 2023-01-10 19:45:06 +02:00
Hitalo Souza
cf95d77584 json2: small refactor after #16896 (#16911) 2023-01-10 11:08:11 +02:00
Hitalo Souza
8a986b994e tools: fix v new abc (#16933) 2023-01-10 09:36:21 +02:00
Delyan Angelov
1582db1a0a comptime: add support for T is $Alias and T is $Function (#16929) 2023-01-10 08:49:04 +02:00
Delyan Angelov
6a32c81070 tests: extract slow tests (prod, valgrind, inout, repl etc), from vlib/v/tests/ to vlib/v/slow_tests/ (#16892) 2023-01-09 23:47:03 +02:00
Hitalo Souza
33a99fe833 json2: fix encoding of struct fields that are aliases (#16925) 2023-01-09 22:43:01 +02:00
Yochem van Rosmalen
0109fe66a6 os: make os.FileMode public (#16923) 2023-01-09 22:34:36 +02:00
Felipe Pena
51907618c3 cgen: fix code generated for a match expression, which returns function (#16922) 2023-01-09 22:30:35 +02:00
Swastik Baranwal
413a8b5f87 comptime: implement field.is_enum (#16920) 2023-01-09 20:12:07 +02:00
yuyi
c2eb4d7065 cgen: fix result or option of multi return (fix #16873) (#16915) 2023-01-09 16:20:15 +02:00
yuyi
286350aa9b cgen: fix json encoding of structs with option fields (skip the fields with a value of none) (#16916) 2023-01-09 15:33:08 +02:00
Hitalo Souza
2ec6e2b209 tools: fix v new <name> web (#16738) 2023-01-09 09:37:46 +03:00
Wertzui123
956b9f650c doc: improve the "Getting started" section (#16910) 2023-01-09 09:37:17 +03:00
JalonSolov
90941b3b1f all: change optional to option (#16914) 2023-01-09 09:36:45 +03:00
yuyi
241109516f checker, cgen: fix aliased optional or result fn call (#16908) 2023-01-08 20:04:17 +02:00
Hitalo Souza
ed0500dcfd docs: add a section about the 3 forms of v init commands at the start (#16905) 2023-01-08 18:34:58 +02:00
Hitalo Souza
fed8b49e46 vweb: add the v new <name> web command for starting new projects to the README.md (#16904) 2023-01-08 18:33:17 +02:00
Felipe Pena
1b78f430ab checker, cgen: support $if T in [$Array, $Struct[operator for comptime type checking (#16896) 2023-01-08 18:22:10 +02:00
Delyan Angelov
942130ff6e ci: make the v gret steps more robust to slow CI runners 2023-01-08 14:56:22 +02:00
MatejMagat305
a99149334c sync.pool: fix pointer cast warning (#16902) 2023-01-08 12:34:46 +02:00
Felipe Pena
a60f34e6dd cgen: fix array_init generated code for reference var (#16894) 2023-01-07 12:04:04 +02:00
Swastik Baranwal
2aced13942 checker: disallow all operations beside assignment, on multi return values (#16890) 2023-01-07 11:53:20 +02:00
Felipe Pena
7fa7fec304 cgen: minor refactor - reduce repeated code (#16886) 2023-01-07 11:49:57 +02:00
Delyan Angelov
de2ed7497a ci: update struct_init_with_interface_pointer_and_embed_test.v to match 2119a24 2023-01-06 15:01:33 +02:00
Delyan Angelov
725456cde0 ci: fix warnings in v -cc gcc -keepc -freestanding -o bel vlib/os/bare/bare_example_linux.v 2023-01-06 14:55:01 +02:00
Delyan Angelov
2119a240e8 checker: follow up to 43d8bc3, separate setting the default type for fields with default expressions into its own independent loop 2023-01-06 14:47:57 +02:00
Felipe Pena
3b594d6cd8 checker, cgen: allow iterating over optional array fields (#16858) 2023-01-06 09:33:11 +03:00
Alexander Medvednikov
868908b80d checker: require unsafe for Struct(voidptr) casts 2023-01-06 09:28:11 +03:00
Hitalo Souza
0146509516 examples: fullstack vweb example (#16761) 2023-01-06 04:36:42 +03:00
Delyan Angelov
43d8bc30f9 checker: fix unset type of a pointer field with default value, when a struct contains an embed (fix #16882) (#16883) 2023-01-05 19:53:37 +02:00
Delyan Angelov
c1a9f42b05 ci: add vlib/v/tests/orm_sub_array_struct_test.v to the skip list for the tests-sanitize-undefined-gcc job 2023-01-05 19:51:44 +02:00
Swastik Baranwal
da68b2d369 checker: remove c.pref.is_test exception for calling private methods in _other_ modules (#16872) 2023-01-05 15:41:18 +02:00
Hitalo Souza
3598e7d08e orm: add tests for fkey: relationship attribute and retrival of joined rows (#16877) 2023-01-05 15:20:15 +02:00
Hitalo Souza
8f217c00e5 x.json2: refactor/fix json2.encode, add more tests (#16790) 2023-01-05 15:17:38 +02:00
Felipe Pena
e3aee748ac cgen: fix code generated for optional comptime var (#16854) 2023-01-05 10:54:51 +02:00
Delyan Angelov
19c9633896 builder: show a hint about v ., on unknown errors, suggesting that the user tried to compile a single .v file from a multi file project (#16878) 2023-01-05 07:45:23 +02:00
Delyan Angelov
66438391d0 v.token,v.parser: use p.tok.kind.precedence(), instead of p.tok.precedence(), since token.Token struct values, are much larger, than just the token.Kind enum values 2023-01-04 17:50:51 +02:00
Delyan Angelov
f9e8a91cd0 v: move cmd/v/help/ to vlib/v/help, to simplify the interaction between module lookup & v recompilation (#16867) 2023-01-04 14:01:05 +02:00
yuyi
b8571c964d cgen: fix json encode struct with optional field (#16866) 2023-01-04 12:41:07 +02:00
yuyi
0a6fc6d280 checker: fix generic stack of sumtype push() (#16855) 2023-01-03 18:29:29 +02:00
yuyi
2378b71f22 cgen: fix comptime if expr with optional or result call (#16853) 2023-01-03 14:38:08 +02:00
Swastik Baranwal
09766c44b6 checker: disallow struct{...val.$(field.name)} (#16852) 2023-01-03 10:21:32 +02:00
Hitalo Souza
2e54a8cb0e x.json2: update tests (#16847) 2023-01-03 10:16:36 +02:00
Felipe Pena
bd2b216ac7 cgen,checker: fix method call with comptime var (#16844) 2023-01-03 10:14:23 +02:00
JalonSolov
395ee2b464 readme: add back align=center to make github happy (#16850) 2023-01-03 10:12:08 +02:00
Ikko Ashimine
24189e02b5 tools: fix typo in vcomplete.v (#16851) 2023-01-03 10:11:06 +02:00
Delyan Angelov
3625a74ec5 os: add test for os.open_append (#16846)
* os: add test for os.open_append

* fix unclosed file in test_eof (it made os.open_append fail only on windows, since it got the previous file content, because the file was locked, and os.rm could not delete it)
2023-01-03 01:11:35 +02:00
Keito Tobichi
d5b9f7d026 io: fix typos (fix #16839) (#16840) 2023-01-02 20:20:52 +02:00
Felipe Pena
b0d39814be cgen, checker: fix conditional evaluation and code generation for $if/$else $if/$else for known true conditions (#16823) 2023-01-02 20:14:12 +02:00
Delyan Angelov
9bee702c62 readme: final update for the instructions for NixOS 2023-01-02 19:39:18 +02:00
Delyan Angelov
d91cf511ca readme: update the instructions for NixOS with the correct ones 2023-01-02 19:35:10 +02:00
Delyan Angelov
c21949456e readme: add instructions for installing the libraries needed for the graphics examples on NixOS 2023-01-02 19:30:01 +02:00
yuyi
f71572a50f parser: fix array of functions direct call (#16838) 2023-01-02 14:12:07 +02:00
yuyi
9d49b69b69 ast: fix inferring generic struct (fix #16830) (#16831) 2023-01-01 17:36:18 +02:00
yuyi
51bb630ea4 checker: fix generic fn with short generic struct init syntax (#16828) 2023-01-01 09:14:55 +02:00
JalonSolov
aaf3e25c3f websocket: simplify and better handle handshake (#16829) 2023-01-01 09:04:09 +02:00
Delyan Angelov
d3a196977f thirdparty: update stb_image.h to its latest version v2.27 (#16825) 2022-12-31 21:25:31 +02:00
Delyan Angelov
3364bf8600 cgen: add g.push_existing_comptime_values and g.pop_existing_comptime_values, use them inside Gen.comptime_for (#16821) 2022-12-31 18:29:19 +02:00
yuyi
1c151fbec9 cgen: fix struct optional field zero init (#16814) 2022-12-31 17:36:14 +02:00
Makhnev Petr
04cb6ae65f tests: improve Teamcity test runner (#16817) 2022-12-31 17:26:18 +02:00
mfont
1e401d1433 bcrypt: fix issue #16769 security problem in compare_hash_and_password (#16815) 2022-12-31 17:18:43 +02:00
Felipe Pena
5daf39bc6a cgen: fix typeof with comptime var (#16816) 2022-12-31 15:57:55 +02:00
yuyi
15c9153f1d cgen: fix fixed array literal range index (#16812) 2022-12-30 13:59:54 +02:00
Felipe Pena
c10bc09e83 checker, cgen: allow $for in alias type (#16810) 2022-12-30 11:27:01 +02:00
Felipe Pena
f4cd3931fb cgen: fix dump fn name using generic var (#16805) 2022-12-30 11:16:59 +02:00
Swastik Baranwal
828cd4fe79 checker: add check for implicit fixed array decomp in function varargs (#16806) 2022-12-30 01:06:41 +02:00
Felipe Pena
c7f1db2b8a cgen: cleanup uneeded C code, when using selectorexpr on $if (#16802) 2022-12-29 20:30:42 +02:00
Delyan Angelov
6229f48830 checker,cgen: implement support for the new FieldData.is_alias field (part 2, follow up to a6bf20f) 2022-12-29 19:14:13 +02:00
yuyi
6a8b6c010c repl: minor cleanup in runner.v (#16804) 2022-12-29 17:55:57 +02:00
yuyi
36ab78d6da parser, cgen: fix anon fn optional call in if expr (#16803) 2022-12-29 17:53:17 +02:00
Delyan Angelov
cd4ea16609 cgen: add more detailed cgen stage timing info on -show-timings 2022-12-29 17:33:40 +02:00
Delyan Angelov
a6bf20f3be builtin: add .is_alias to FieldData too (part 1, unimplemented yet) 2022-12-29 12:43:55 +02:00
yuyi
f4b110b1a4 vrepl: fix $tmpl('hello.txt') (fix #16789) (#16793) 2022-12-29 11:30:25 +02:00
Felipe Pena
ed06618498 cgen: fix generic func arg type when passing array compile-time field (#16798) 2022-12-29 11:23:57 +02:00
Felipe Pena
2ebd3f0cdb checker,cgen: make boolean field.is_<field> accessible at compile-time as well (#16796) 2022-12-29 00:19:47 +02:00
Swastik Baranwal
ad9ca349dc cgen: fix generics array delete (#16794) 2022-12-29 00:15:47 +02:00
Delyan Angelov
4718a818b8 vfmt: fix alignment of value formatting for "x := {.: 1, : 2}" 2022-12-28 18:06:32 +02:00
Delyan Angelov
1709d175bb tools/fast: make the header a link to /, to ease navigation 2022-12-28 13:51:26 +02:00
Delyan Angelov
101aa4aeb0 tools/fast: add navigation links to older stat pages 2022-12-28 13:35:30 +02:00
Felipe Pena
0f37ff197b checker: fix fn call with generic []T arg (#16781) 2022-12-28 11:05:11 +02:00
yuyi
b171102b03 os: minor optimization in os.v (#16791) 2022-12-28 10:28:47 +02:00
yuyi
b9996619d5 cgen: fix result/option breaks execution order in if statements (fix #16663) (#16778) 2022-12-28 10:26:39 +02:00
Delyan Angelov
afdb09708e ci: comment out the -autofree compilation for gitly for now 2022-12-27 20:51:45 +02:00
Larpon
161595b041 examples: use math.vec in examples/sokol/particles (#16780) 2022-12-27 15:19:08 +02:00
Felipe Pena
c5c7b3a054 checker: fix comptime var param passing with comptime selector (#16777) 2022-12-27 15:14:58 +02:00
Delyan Angelov
a8f6f9ed60 checker: more precise error handling of large binary literals like 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 (#16775) 2022-12-27 15:13:15 +02:00
Delyan Angelov
508bfbf892 time: do not panic for time.parse("2020-02-02 20.02.20")!, just return an error instead (fix #16779) 2022-12-27 13:01:01 +02:00
Delyan Angelov
6b3f8f519d cgen: fill in the new FieldData fields, add tests (#16774) 2022-12-26 23:35:13 +02:00
Felipe Pena
9b28a7aa96 checker,cgen: fix comptime value recognition on generic arguments (#16768) 2022-12-26 18:44:18 +02:00
yuyi
3a1e7b71ea cgen: fix array filter with an inline closure (fix #16770) (#16772) 2022-12-26 16:14:28 +02:00
Delyan Angelov
3d545ee0cd builtin: add more fields to FieldData (will be implemented later in a PR, to ease bootstrapping) 2022-12-26 16:05:14 +02:00
Delyan Angelov
94a36c5ca4 tests: remove module main from tests, that do not need to be internal 2022-12-26 15:31:23 +02:00
Delyan Angelov
728b4cffc3 ci: reorder v_apps_and_modules_compile.yml so that quick checks are done first 2022-12-26 12:56:36 +02:00
yuyi
68883fc4d9 os: fix os.file_ext('/tmp/.gitignore') previously returning '.gitignore' => it now returns '' (#16771) 2022-12-26 12:53:38 +02:00
yuyi
64ed007f94 cgen: fix generic struct init with inconsistent generic optional types (#16766) 2022-12-25 12:06:13 +02:00
yuyi
21d6bd930e ast, cgen: fix printing nested generic struct (#16758) 2022-12-25 09:57:16 +02:00
Brian Callahan
85b4af5440 make: add OpenBSD detection to GNUmakefile (#16760) 2022-12-25 09:55:41 +02:00
Delyan Angelov
776fbdfb23 readme: cleanup the additional graphics libraries installation instructions 2022-12-24 11:59:30 +02:00
Delyan Angelov
d55715884a readme: add instructions for installing the libraries needed for the graphics examples on Fedora 2022-12-24 11:55:06 +02:00
Felipe Pena
6a179a2926 checker: add int signedness mismatch checking for function call arguments (#16750) 2022-12-24 06:28:35 +02:00
yuyi
0128d2dd1c ast, parser: fix wrong type name of nested generics (#16749) 2022-12-24 06:19:51 +02:00
Felipe Pena
e9cad6f09d ci: fix v-apps-compile job for AdventOfCode, by adding v install regex too (#16752)
Missing pcre dependency
2022-12-24 06:14:48 +02:00
Charles WANG
9dbc2afc5b net.html: fix typo in README.MD (#16747) 2022-12-23 09:37:08 +02:00
Felipe Pena
b21e5b71ba cgen: fix call arg type changing on match expr (#16744) 2022-12-23 01:58:52 +02:00
Delyan Angelov
fc5826b7ca cgen: minimise sizeof(EmptyStruct) to 0 for gcc/clang and to 1 for tcc/msvc, by changing EMPTY_STRUCT_DECLARATION and EMPTY_STRUCT_INITIALIZATION (#16733) 2022-12-22 21:47:39 +02:00
yuyi
e01dac885c builtin: fix m.len to 0, after calling map.clear() (#16720) 2022-12-22 21:36:33 +02:00
Delyan Angelov
f9043c84a7 builtin: optimise the initialisation of the common 1 byte element arrays []u8 2022-12-22 20:41:32 +02:00
Delyan Angelov
8f8a186158 builtin: support -d trace_vmemset, -d trace_vmemcmp, -d trace_vmemmove and -d trace_vmemcpy too 2022-12-22 20:08:53 +02:00
Delyan Angelov
b67705f568 builtin: move the -d trace_*alloc lines at the start of their corresponding functions, implement -d trace_memdup too 2022-12-22 19:36:15 +02:00
Delyan Angelov
3da4f37b01 cgen: improve generated source compatibility with latest Alpine (lacking libexecinfo-dev and execinfo.h) and the prebuilt tcc (#16743) 2022-12-22 15:01:51 +02:00
yuyi
e519bdf0eb checker: check generic method receiver type mismatch (#16739) 2022-12-22 13:37:46 +02:00
yuyi
82a3551313 checker, cgen: fix match expr with branch returning (#16741) 2022-12-22 12:55:44 +02:00
Swastik Baranwal
3c5cfa22d1 parser: disallow the array init: attr, when the len: attr is not provided (#16735) 2022-12-21 21:24:16 +02:00
Delyan Angelov
87f8069728 ci: fix warnings for compiling builder_test.v too 2022-12-21 21:14:21 +02:00
Delyan Angelov
46ced75184 ci: fix v test-self failures related to cmd/tools/vcreate_test.v 2022-12-21 21:13:06 +02:00
Delyan Angelov
68501677e3 ci: fix gg-regressions failure 2022-12-21 21:03:47 +02:00
Alexander Medvednikov
88e33a83de gg: fix draw_image on macos native; vcreate: vweb template 2022-12-21 19:33:37 +03:00
yuyi
ccbb8ab0ca ast, parser: fix generic struct init with nested generic struct (#16736) 2022-12-21 18:32:54 +02:00
Delyan Angelov
1cde55478d cgen: fix cgen errors for overloaded operators using reference types for the receiver and operand (fix #16725) (fix #15859) (#16726) 2022-12-21 09:10:30 +02:00
Swastik Baranwal
d19c1ef087 vpm: fix the direct installation of github repositories via the --git flag (#16724) 2022-12-20 17:38:08 +02:00
Felipe Pena
2f9becc98d cgen: fix debug generated code with -g, while fixing #16690 (#16723) 2022-12-20 16:41:42 +02:00
Delyan Angelov
3c920f2ee6 x.json: fix parsing of time fields, that have just a single date encoded inside the parsed string (fix #16722) 2022-12-20 16:34:09 +02:00
pancake
c84eb29b78 js: use write() on the freestanding backend (#16704) 2022-12-20 13:16:06 +02:00
Makhnev Petr
11521a70e4 readme: add modules badge and fix twitter url/badge inconsistency with others (#16716) 2022-12-20 10:56:10 +03:00
John
eb8e8b8642 rand: add Blackman/Vigna xoroshiro128++ PRNG (#16712) 2022-12-20 10:53:30 +03:00
Felipe Pena
0fe7ae3a60 cgen: remove repeated code (#16718) 2022-12-20 10:52:37 +03:00
Larpon
7e4dc24f1b math: add math.vec module with generic 2D, 3D and 4D vector operations (#16710) 2022-12-19 18:10:48 +02:00
yuyi
2090e4a12f ast, cgen: optimize generic struct with inconsistent generic types (#16708) 2022-12-19 15:02:27 +02:00
Delyan Angelov
bcdf1b95c1 docs: add a note about test files being compiled as separate V programs, independently from normal code 2022-12-19 13:15:39 +02:00
Delyan Angelov
353fdb4ca0 ci: workaround for v vet failing for v clean-code over the new v bench script (using \ in its path on windows). 2022-12-19 12:31:16 +02:00
Swastik Baranwal
8873127687 v doc: properly highlight the new generics syntax [] in the CLI results of v doc arrays etc (#16703) 2022-12-19 12:12:46 +02:00
Delyan Angelov
cbd34cd6e7 bench: add bench_string_key_in_map_vs_string_value_in_array.v 2022-12-19 11:56:00 +02:00
yuyi
aad95ac818 cgen: fix generic struct init with inconsistent generic types (fix #16677) (#16702) 2022-12-19 10:43:27 +02:00
Felipe Pena
04936b00c5 cgen: fix struct selector with or block (#16695) 2022-12-18 14:22:06 +02:00
Delyan Angelov
de5ae63401 parser: improve precision of struct field type positions in errors 2022-12-18 13:34:39 +02:00
Swastik Baranwal
5b4a16e864 checker: add err for unknown generic struct field (#16698) 2022-12-18 11:46:37 +02:00
JalonSolov
20aaf4de09 README: replace deprecated align attribute, correct tcc info in C compiler section, fix some grammar and spacing issues (#16699) 2022-12-18 11:44:23 +02:00
yuyi
ba07e48691 ast, checker: fix checking generic struct type mismatch (#16701) 2022-12-18 10:29:44 +02:00
Delyan Angelov
9f1239c56e vweb,net: fix vweb crash when the connection was closed prematurely (tested with Chrome on windows, refreshing as fast as possible) 2022-12-17 19:08:59 +02:00
yuyi
e83a8416d5 ast, parser: fix generic struct init with inconsistent generic types (#16697) 2022-12-17 18:17:43 +02:00
Felipe Pena
9921598c91 cgen: fix struct field initialisation with a fixed array (#16692) 2022-12-17 18:15:17 +02:00
Delyan Angelov
1aec40a126 vweb: flush stdout after the Running app on message, fix potential invalid map value access in serve_if_static 2022-12-17 18:04:50 +02:00
Felipe Pena
65a020e385 cgen: fix comptime checking optional type with IS operator (#16688) 2022-12-16 16:53:04 +03:00
l-m
f0a252d0e6 builtin: apply .nogrow flags to gcboehm array (#16689) 2022-12-16 07:57:50 +02:00
Delyan Angelov
14cc43b0f6 v ast: add forgotten fields since 2022/06/01 2022-12-15 21:18:54 +02:00
Delyan Angelov
0a11955284 parser: support an unambiguous sizeof[T]() and isreftype[T]() (part 1) (#16684) 2022-12-15 19:21:52 +02:00
Ikko Ashimine
e5e73ebbfa regex: fix typo in regex.v (#16683) 2022-12-15 18:54:07 +02:00
Swastik Baranwal
bd1d96de0e cgen: add support for alias map keys (#16682) 2022-12-15 18:53:23 +02:00
Delyan Angelov
3643785981 pref: deprecate -error-limit in favour of the documented -message-limit option. 2022-12-15 10:37:57 +02:00
yuyi
fd472d2d41 toml: minor cleanup in toml tests (#16679) 2022-12-15 10:16:42 +02:00
Makhnev Petr
db2111235e tests: add a teamcity output format for V's test runner (#16681) 2022-12-15 09:29:09 +02:00
Delyan Angelov
3fa23b789c ci: add new dependencies for VSL (hdf5 libs and tools) 2022-12-15 08:37:10 +02:00
JalonSolov
5b008fca41 make.bat: fix path backslashes to forward slashes for more compatibility, change quoting to be more consistent (#16678) 2022-12-14 22:48:34 +02:00
Felipe Pena
c3ee26f15f checker,cgen: fix dump when using comptime variable val.${field.name} (#16671) 2022-12-14 20:45:28 +02:00
Delyan Angelov
f762d46c84 pg: add compatibility.h, using a PG_VERSION_NUM check in the preprocessor, to just hardcode the missing CONNECTION_ numbers 2022-12-14 18:27:42 +02:00
Delyan Angelov
34f5255bb5 ci: fix a failing test for v test .github/workflows 2022-12-14 17:02:01 +02:00
Delyan Angelov
3b683f11e0 pg: comment out C.CONNECTION_GSS_STARTUP, which is not available on Debian 10 (PG 11) 2022-12-14 16:39:29 +02:00
yuyi
8e3a90ae79 cgen: minor cleanup in struct_init() (#16676) 2022-12-14 15:25:09 +02:00
yuyi
8ab4c7742c ast, checker: fix generic struct init with inconsistent generic types (#16675) 2022-12-14 14:57:12 +02:00
Delyan Angelov
7f23ae595b ci: add a separate download_vc target to Makefile for FreeBSD 2022-12-14 14:05:10 +02:00
Delyan Angelov
93a1cd5aab freebsd: update Makefile to use --filter=blob:none for vc/ 2022-12-14 13:25:40 +02:00
Delyan Angelov
173b1895d6 pg: cleanup implementation, make -cstrict pass with both gcc-11 and clang-12 (by tightening the C wrapper declarations) 2022-12-14 13:17:00 +02:00
Hitalo Souza
70bb989537 doc: update the README for json2 (#16657) 2022-12-14 10:21:29 +02:00
l-m
acbd93b54c builtin: add .nogrow and .nofree flags to array (#16661) 2022-12-14 09:44:14 +02:00
Subhomoy Haldar
b07e447764 encoding.html: add escape() function (#16666) 2022-12-13 22:10:57 +02:00
yuyi
69f7c45bec builtin: fix array init with array default (#16664) 2022-12-13 18:05:33 +02:00
Felipe Pena
738fe77300 cgen: fix short circuiting behaviour of logical expressions, when several PrefixExpr's are used in if conditions (#16660) 2022-12-13 13:09:03 +02:00
Delyan Angelov
992621bd91 bench: add a small performance comparison script bench_json_vs_json2.v 2022-12-12 10:26:04 +02:00
Hitalo Souza
b682e9ec0b json2: decode time.Time, supporting unix timestamps (like json), as well as rfc3339 datetimes (#16653) 2022-12-12 10:06:29 +02:00
yuyi
8225622da5 checker: check smartcasting requires either an immutable value, or an explicit mut keyword before the value (#16654) 2022-12-12 09:22:56 +02:00
yuyi
d87e400e77 transformer: clean up expr_stmt_match_expr() (#16655) 2022-12-12 08:41:02 +02:00
Felipe Pena
1e7208d28b parser: fix initialization for array of Option type - []?Cell{} (#16652) 2022-12-12 08:40:05 +02:00
Hitalo Souza
d7c244e5ec x.json2: support time.Time values in encode (#16643)
* feat: json2 time.Time encode

* refactor: best var name

* fix: use 'RFC 3339' as pattern in json encode

* fix: unused var for unaliased_typ

* fix: improve test

* use the clearer test after V ad24c22, that made format_rfc3339 more stable

Co-authored-by: Delyan Angelov <delian66@gmail.com>
2022-12-11 16:54:28 +02:00
Delyan Angelov
ad24c22250 time: add more UTC/local time conversion functions, make Time.format_rfc3339 more stable 2022-12-11 13:34:01 +02:00
yuyi
73e886eafe checker: fix generic fn returning result (#16646) 2022-12-11 12:34:58 +02:00
Delyan Angelov
94098eef79 time: use UTC time in Time.format_rfc3339, make test more robust 2022-12-11 10:36:29 +02:00
Delyan Angelov
2ecb892985 time: add Time.format_rfc3339() method 2022-12-11 10:23:05 +02:00
JalonSolov
3ea9e3aba9 github: make Environment field in feature request match bug report (#16645) 2022-12-11 09:06:37 +02:00
Hitalo Souza
e8c0b098b0 x.json2: add encode_pretty/1 (#16634) 2022-12-10 20:44:23 +02:00
Delyan Angelov
4b2699fddd cgen: fix copying of a fixed array parameter to a function (fix #16640) 2022-12-10 20:10:01 +02:00
Hitalo Souza
30b39bebde x.json2: refactor json tests (#16638) 2022-12-10 18:44:20 +02:00
JalonSolov
44a539f186 github: change bug template Envionment field to textarea (#16641) 2022-12-10 18:39:22 +02:00
lemon
799af2adad native: support simple multi return (#16628) 2022-12-10 16:26:43 +02:00
Alexander Medvednikov
42a9eaac0e regex: make match_string() receiver immutable 2022-12-10 13:03:42 +03:00
Keito Tobichi
7c4f45a375 docs: change <> to [] in docs.md part2 (#16633) 2022-12-10 11:36:59 +02:00
Keito Tobichi
ad5290677c docs: change <> to [] in docs.md (#16632) 2022-12-10 10:47:03 +02:00
Delyan Angelov
7c02274754 v.pkgconfig: support PKG_CONFIG_PATH_DEFAULTS for overriding the default search path list too (enable easier -m32 with a custom tcc cross compiler) 2022-12-10 00:50:24 +02:00
Felipe Pena
1ba1f99b9c orm: declare missing functions to handle literal types (#16627) 2022-12-09 20:34:34 +02:00
Hitalo Souza
b6c2aab092 json2: support encoding of optional struct fields (#16521) 2022-12-09 18:08:24 +02:00
Felipe Pena
ba8e61ebf3 cgen: fix return typeof[T]() in generic functions (#16626) 2022-12-09 17:24:47 +02:00
yuyi
6c0f22416f cgen: fix if cond with result or optional in infix expr (#16625) 2022-12-09 12:01:14 +02:00
yuyi
68fb4e9fe5 cgen: fixevaluation order for match expressions inside boolean ones (fix #16554) (#16616) 2022-12-09 11:56:38 +02:00
Carter
eb88f7e255 builtin: fix bug with string.split_into_lines, when lines have extra CR's at their end (#16620) 2022-12-09 09:15:50 +02:00
Delyan Angelov
7091010a53 arrays: add map_of_counts/1, map_of_indexes/1 as well as index_of_first/2, index_of_last/2 utilities (#16618) 2022-12-09 00:37:07 +02:00
Felipe Pena
f365771499 cgen: fix nested struct generation for globals for gcc (#16614) 2022-12-08 21:38:01 +02:00
Delyan Angelov
d62fc777c9 ci: add a 'Build AdventOfCode' step in the v-apps-compile job 2022-12-08 11:15:07 +02:00
谢克
32c80c53b3 cgen: fix generic functions returning none or error values with generic result types (#16613) 2022-12-08 11:08:39 +02:00
Felipe Pena
2261606b56 checker: disallow Bar{...foo} when Bar needs more fields, than what foo has (#16609) 2022-12-07 16:56:07 +02:00
Delyan Angelov
458e68e196 orm,sqlite,mysql,pg: cleanup import v.ast, using typeof[Type]() 2022-12-07 13:40:46 +02:00
yuyi
4eb81d2f05 checker: improve error messages of missing generic type names (#16610) 2022-12-07 11:29:18 +02:00
Delyan Angelov
48a7de643e all: support typeof[ T ]().idx and typeof[ T ]().name, where T can be any type, including ![]&string (#16513) 2022-12-07 11:26:27 +02:00
Swastik Baranwal
bb705c01d2 parser: add proper error msg for := used in const decl (#16607) 2022-12-06 22:44:33 +03:00
yuyi
921416d821 parser: fix parsing generic types using '[]' in anon fn decl (#16605) 2022-12-06 18:15:59 +02:00
Felipe Pena
cf015e5073 checker: add clearer errors for break/continue used within a $for loop (#16600) 2022-12-06 17:27:59 +02:00
Swastik Baranwal
ada8643ac5 checker: disallow using builtin type names for const names (#16599) 2022-12-06 15:44:25 +02:00
Larpon
5fc7b6d3d6 tools: add tests for vcomplete (#16587) 2022-12-06 13:02:32 +02:00
yuyi
e35f5f290e cgen: fix string of map with generic struct value (#16595) 2022-12-06 12:38:05 +02:00
yuyi
a96e2e7093 parser: fix parsing embedded generic interface using '[]' (#16603) 2022-12-06 12:37:36 +02:00
yuyi
46bb62955b cgen: fix generic array init with fields (#16601) 2022-12-06 09:33:26 +02:00
Felipe Pena
edfaa76b3e checker: fix panic caused by compile-time code within or block (#16602) 2022-12-06 09:26:04 +02:00
Delyan Angelov
94dc3c1c36 ci: fix the platform image for gg-regressions to ubuntu-20.04 (github is migrating ubuntu-latest to 22.04) 2022-12-06 09:13:02 +02:00
Delyan Angelov
70fed41660 ci: override VTMP to /tmp for the jobs gg-regressions and doom-regressions 2022-12-05 17:07:48 +02:00
Hitalo Souza
5288c613ef json2: decode refactor/fix (#16588) 2022-12-05 16:58:44 +02:00
yuyi
50110d4c19 all: replace generic '<>' with '[]' in .vv files (#16593) 2022-12-05 16:32:15 +02:00
yuyi
7e9e2ff459 cgen: fix if expr with multiple array call (fix #16583) (#16589) 2022-12-05 12:07:39 +02:00
yuyi
59c979c8d2 checker: check generic interface type specifing type names (fix #16576) (#16591) 2022-12-05 10:05:32 +02:00
Larpon
349ce08a11 tools: fix vcompletion for single-file directories (#16586) 2022-12-05 09:15:43 +02:00
Swastik Baranwal
ce06c2818d checker: add disallow none operations and range (#16584) 2022-12-05 08:50:36 +02:00
yuyi
ffc73bf643 builder: fix v builder error (#16590) 2022-12-05 08:48:45 +02:00
Delyan Angelov
d8d75ee67e v.builder: fix v -os wasm32_emscripten examples/2048 on windows 2022-12-04 17:49:33 +02:00
Delyan Angelov
f5d0ba318e testing: support new events in the output modules of v test: .cmd_begin sent right before a _test.v execution, and .cmd_end sent right after a _test.v execution 2022-12-03 20:06:46 +02:00
RGBCube
5acd855525 term: add format_esc/1 (#16574) 2022-12-03 14:01:39 +02:00
Delyan Angelov
bf0c8a0d96 sync: fix compilation of V on m1 with tcc 2022-12-02 23:17:46 +02:00
Delyan Angelov
d09c8c914b testing: refactor the v test implementation to make supporting different output modes easier 2022-12-02 18:12:42 +02:00
Delyan Angelov
e419faf746 all: fix dependant->dependent typos, cleanup comments 2022-12-02 12:51:10 +02:00
Delyan Angelov
675c362f57 v.util: cleanup util.path_styled_for_error_messages/1 2022-12-02 11:48:01 +02:00
Delyan Angelov
c77344e0a2 checker: add a return *x suggestion, to the error fn ... expects you to return a non reference type ..., but you are returning ... instead 2022-12-02 10:40:36 +02:00
yuyi
f16722596c all: replace generic '<>' with '[]' in error messages and comments (#16571) 2022-12-02 09:22:48 +02:00
Tim Marston
cbe64cb543 checker: allow struct updates from struct aliases (#16567) 2022-12-02 00:28:10 +02:00
RGBCube
18d98a5e16 .github: clean issue templates (#16566) 2022-12-01 18:29:59 +02:00
Larpon
6e24f7e13a gg: always use 4 channels in init_sokol_image (#16564) 2022-12-01 18:54:37 +03:00
Delyan Angelov
161847ed1a v.pref: make -b unknown_backend an error, with a more informative diagnostic message 2022-12-01 15:28:51 +02:00
RGBCube
02f5c59340 docs: remove Android from the common installation section header, as it has its own section (#16563) 2022-12-01 14:59:44 +02:00
Delyan Angelov
32976863a8 github: add existing "Unit: Documentation" label to the documentation issue template. 2022-12-01 14:49:50 +02:00
yuyi
c06696bc9a cgen: fix printing multi-reference struct (#16560) 2022-11-30 21:30:15 +02:00
yuyi
fd04c1a03a cgen: fix error of match expr (fix #16554) (#16555) 2022-11-30 12:04:20 +02:00
Christopher Fore
3175bf374d Add Arch command for MingW (#16558) 2022-11-30 00:17:34 +02:00
Delyan Angelov
675a1be975 math: remove the deprecated math.mathutil module too 2022-11-29 14:56:40 +02:00
Delyan Angelov
3fff786f36 math: remove the deprecated math.util module 2022-11-29 14:42:46 +02:00
Delyan Angelov
952f4644c5 math.big: remove import math dependency (math.big only uses min/max/abs) 2022-11-29 14:42:46 +02:00
Delyan Angelov
6ef3dfdea9 sokol: fix v -Wimpure-v examples/2048/ 2022-11-29 14:42:45 +02:00
Delyan Angelov
7df8f063ed builtin: fix typo 2022-11-29 14:42:44 +02:00
yuyi
dff61300fb table: optimize fn_type_signature() (#16552) 2022-11-29 13:13:58 +02:00
Swastik Baranwal
58e150df12 parser: add a better error msg for using ..., instead of .. in for a in 1...10 { (#16547) 2022-11-28 10:37:12 +02:00
yuyi
d257e43932 checker: fix 'return none' in void optional function (#16545) 2022-11-28 10:29:02 +02:00
yuyi
7d8c386721 datatypes: change optional to result (#16546) 2022-11-28 10:24:47 +02:00
Delyan Angelov
1d24dbe602 builtin: document string.to_wide() and string_from_wide()/1 2022-11-28 09:46:04 +02:00
Delyan Angelov
73675dca87 builtin: move v_segmentation_fault_handler to builtin.c.v, make it more informative 2022-11-27 12:11:06 +02:00
Delyan Angelov
fdbd40d806 scanner: make Scanner.peek_token more robust (p.peek_token(-999999) will return an EOF token, instead of garbage data) 2022-11-27 12:09:43 +02:00
Delyan Angelov
50b73abc62 parser: add p.show() to ease debugging parser problems, that need more context
Using it, produces output like this on stdout:
```
>> vlib/v/tests/typeof_type_test.v:4:        keyword `typeof`  token `(`  token `[`      keyword `fn`                      token `(`  name `s`  name `string`
>> vlib/v/tests/typeof_type_test.v:8:        keyword `typeof`  token `(`  token `[`      name `int`                        token `]`  token `)`  token `.`
>> vlib/v/tests/typeof_type_test.v:9:        keyword `typeof`  token `(`  token `[`      name `int`                        token `]`  token `)`  token `.`
>> vlib/v/tests/typeof_type_test.v:13:       keyword `typeof`  token `(`  token `[`      name `u32`                        token `]`  token `)`  token `.`
>> vlib/v/tests/typeof_type_test.v:14:       keyword `typeof`  token `(`  token `[`      name `u32`                        token `]`  token `)`  token `.`
>> vlib/v/tests/typeof_type_test.v:18:       keyword `typeof`  token `(`  token `[`      name `string`                     token `]`  token `)`  token `.`
```

Note: this tracing output is *deliberately on `stdout`*, instead of `stderr`,
so that you can filter it more easily, without saving it to a file first, i.e.
you can use it while developing/debugging parser issues like this:
`./v -o vnew cmd/v && ./vnew some_file.v | grep some_file.v`

-> this will show only the parsing context for the constructs you are debugging,
for that specific file *only*, instead of for all of `builtin` and the imported files etc.
2022-11-27 11:13:42 +02:00
yuyi
cf3dda2a58 datatypes: fix fsm.set_state() and cleanup fsm module (#16539) 2022-11-27 09:10:08 +02:00
Vincenzo Palazzo
8543d5e055 checker: improve mut arg error msg (#16540) 2022-11-27 07:07:35 +03:00
yuyi
ef5be22f81 all: replace generic <> with [] - part 2 (#16536) 2022-11-26 18:23:26 +02:00
yuyi
b19b97e7b1 generic: replace generic <> with [] part 1 - allow for both (#16532) 2022-11-26 08:59:42 +02:00
Swastik Baranwal
a9b41d2980 all: add support for const ident in match range (#16526) 2022-11-26 08:56:00 +02:00
yuyi
dee75fe970 checker: perfect infer_struct_generic_types() (#16524) 2022-11-24 19:30:02 +02:00
yuyi
f6cc88fa69 tests: add new test for #16519 (#16520) 2022-11-24 15:56:07 +02:00
yuyi
f0a23c8d3c cgen: fix fn call of sumtype with alias fntype variant (#16519) 2022-11-24 12:05:57 +02:00
yuyi
8b5c75c481 cgen: fix sumtype with alias fntype variant (#16516) 2022-11-23 19:46:58 +03:00
shove
d632e84090 cgen: fix comptime optional methods call and optional field (fix #16499 #16465) (#16503) 2022-11-23 19:08:49 +03:00
Delyan Angelov
a987f84b15 ci: skip the very slow running tests in v test-self, when -asan-compiler or -msan-compiler is passed as well. 2022-11-22 19:52:43 +02:00
Subhomoy Haldar
f7a11b8e50 toml: update value_opt syntax and add missing documentation (#16510) 2022-11-22 19:45:12 +02:00
yuyi
7c7ebd648d checker: check assigning generic function to a variable (#16507) 2022-11-22 17:56:49 +02:00
yuyi
27cdf5ae0e checker: minor cleanup in checker module (remove pub from most of checker's methods) (#16505) 2022-11-22 17:50:26 +02:00
Delyan Angelov
7d57559b70 datatypes: make the out of bounds errors for lists APIs more detailed 2022-11-22 13:42:29 +02:00
yuyi
cc7e6006f9 checker: fix generic fn with short generic struct init syntax (#16504) 2022-11-22 13:27:49 +02:00
lemon
00383edd3d native: add more operator support for floats on amd64 (#16498) 2022-11-21 12:48:24 +02:00
Delyan Angelov
c744030665 tests: add a watchdog thread to live_test.v to prevent it from blocking the whole CI on slow sanitized jobs 2022-11-21 12:24:54 +02:00
Delyan Angelov
c286775d9f strconv: add test_atof_converter to the tests, as suggested by the code review 2022-11-21 07:41:41 +02:00
Delyan Angelov
6cd1723deb strconv: fix float_prec := 1.9999999999999999 + 0.0000000000000000005 being 0.5 (fix #16448) (#16495) 2022-11-21 03:57:51 +03:00
RGBCube
bffe7bd7ab github: add discord link to config.yml (#16497) 2022-11-20 21:33:28 +02:00
Delyan Angelov
0e727ec50a checker: cleanup obsolete code for compatibility between byteptr and &byte (#16494) 2022-11-20 16:44:58 +02:00
Delyan Angelov
cb336c7dc7 net.http: remove ending \r from response.status_msg, add more tests 2022-11-20 16:22:43 +02:00
Subhomoy Haldar
aae63f5eb5 tools: gitignore the bin/ folder in new V projects (created by v init) (#16493) 2022-11-20 14:43:33 +02:00
Hitalo Souza
45854882b9 builtin, cgen: support FieldData.unaliased_typ, use it for generalising x.json2 (able to encode type aliased struct fields) (#16469) 2022-11-20 11:18:14 +02:00
Swastik Baranwal
06764bc559 checker: disallow taking address of optional fields for now (#16487) 2022-11-19 22:03:39 +02:00
Delyan Angelov
531c145ae7 Update bug-report.yml 2022-11-19 20:58:50 +02:00
Delyan Angelov
9d8e307ed9 Add a link to the Q&A category in the discussions 2022-11-19 20:56:18 +02:00
shove
5ef4e0c9be cgen: fix "fn()?.field?" expr cgen error (fix #16482) (#16488) 2022-11-19 20:30:24 +02:00
RGBCube
05e562cb3c doc: return none instead of error in the iterator example (#16486) 2022-11-19 19:11:56 +02:00
Delyan Angelov
6b0743bb07 x.json2: add support for i8, i16, u8, u16, u32 (fix #16484) 2022-11-19 12:03:04 +02:00
shove
79b4cfb42a all: correct the first letter of error message from uppercase to lowercase (#16481) 2022-11-19 10:43:25 +02:00
shove
092f984708 ast, cgen: fix match struct.field? {...} (#16478) 2022-11-19 10:42:36 +02:00
RGBCube
2d9808b2dc term: add term.slow_blink/1 and term.rapid_blink/1 (#16470) 2022-11-18 19:03:14 +02:00
Přemek Vyhnal
92be90300c doc: mention the $embed_file return type, and link to its documentation (#16467) 2022-11-18 12:54:17 +02:00
Ulises Jeremias Cornejo Fandos
914007fd83 github: update templates to use latest github issues features (#16468) 2022-11-18 12:47:17 +02:00
Hitalo Souza
74613bd636 x.json2: generic-based encoder (finish PR#15137) (#16464) 2022-11-18 11:09:24 +02:00
Swastik Baranwal
44e2149baa cgen: add escaping for near, far and huge keyword ptrs (#16463) 2022-11-17 23:42:09 +02:00
Delyan Angelov
886abcdf59 ci: bump timeout-minutes to 240, for all sanitized jobs 2022-11-17 17:35:51 +02:00
shove
ae816b1719 parser: fix if-guard for struct optional fields (fix #16460) (#16461) 2022-11-17 15:30:16 +03:00
shove
74efd2621b checker: fix struct field unsign type check (fix #16457) (#16458) 2022-11-17 09:20:42 +02:00
Swastik Baranwal
360457e021 checker: disable overriding and importing of builtin sym types (#16452) 2022-11-17 09:10:03 +02:00
yuyi
cb9e945aa0 cgen: clean and improve need_tmp_var_in_match() (#16451) 2022-11-17 09:08:45 +02:00
shove
37700502f5 all: implement struct field optional and disallow storing result (#16392) 2022-11-17 07:51:50 +02:00
Spydr
41dd8985fc native: use enum values instead of strings for identifying builtin functions (#16450) 2022-11-17 07:44:08 +02:00
shove
49277f7aa8 cgen: fix dump(nil), dump(voidptr) (fix #16455) (#16456) 2022-11-17 07:41:07 +02:00
yuyi
523ccbcb70 cgen: fix if expr with sumtype value of map (#16445) 2022-11-16 14:59:34 +02:00
Larpon
b60132d2ac checker: rename test assing -> assign (#16446) 2022-11-16 14:46:36 +02:00
Delyan Angelov
9bb1867be0 os: refactor err == IError(os.Eof{}) to err is os.Eof 2022-11-16 00:53:45 +02:00
Delyan Angelov
ddc1a1fc08 checker,cgen: support const y = term.yellow, then println(y('abc')) (#16436) 2022-11-15 19:51:57 +02:00
Swastik Baranwal
dc81d755e8 checker: disallow using unsafe { none } (#16431) 2022-11-15 18:55:07 +02:00
Basil
fe2db64384 tests: add unsafe block for the int->enum cast in bench_compare_tokens.v (#16438) 2022-11-15 18:34:44 +02:00
JalonSolov
5dc5766def doc: minor update for $\{\} (#16440) 2022-11-15 18:33:33 +02:00
yuyi
017ace6ea7 vfmt: change all '$expr' to '${expr}' (#16428) 2022-11-15 16:53:13 +03:00
Ikko Ashimine
56239b4a23 toml: fix typo in parser.v (#16430) 2022-11-14 21:08:22 +03:00
Swastik Baranwal
58cee6ccc8 checker: disallow none type in struct fields (#16425) 2022-11-14 17:48:00 +03:00
yuyi
91ecfb917c checker: fix generic fn casting &u8 to &alias to u32 (#16420) 2022-11-14 17:37:53 +03:00
Alexander Medvednikov
37583b04b4 gg: make create_image's receiver immutable 2022-11-14 17:25:42 +03:00
Dominik Pytlewski
f44af02e32 sqlite: affected rows count (#16426) 2022-11-14 17:23:42 +03:00
yuyi
1a4d1aece4 checker: minor cleanup and optimization in method_call() (#16421) 2022-11-13 22:33:36 +02:00
Delyan Angelov
eb11b0149d tools: fix git_pre_commit_hook.vsh on windows 2022-11-13 21:57:10 +02:00
Delyan Angelov
1978176c22 tools: add an utility cmd/tools/git_pre_commit_hook.vsh script
That script can be used to ensure that all commited V files are vfmt-ed,
i.e. it will run `v fmt -w ` on them before commiting them.

To use the script in your V project, you need to be in the main folder
of your project, then do the equivalent of:
```sh
cp /PATH/TO_YOUR/V/cmd/tools/git_pre_commit_hook.vsh .git/hooks/pre-commit
chmod 755 .git/hooks/pre-commit
```

Note: you can use this command:
`git config --bool --add hooks.stopCommitOfNonVfmtedVFiles true`
... to make it just *prevent* the commiting of unformatted .v files,
i.e. stop the commiting, if they are not, but *without modifying them*
automatically (you will then need to run `v fmt -w` on them manually).

Note 2: Git supports the option `--no-verify`, to temporarily disable all hooks.
2022-11-13 21:22:46 +02:00
Hitalo Souza
38555a92e1 time: change days_from_civil to days_from_unix_epoch, add date_from_days_after_unix_epoch (#16363) 2022-11-13 14:30:14 +02:00
Hitalo Souza
7cfaacbe7a doc: add more examples to vlib/time/README.md (#16362) 2022-11-13 13:48:07 +02:00
yuyi
5a28699edb cgen: minor cleanup in auto_str_methods.v (#16411) 2022-11-13 11:59:32 +03:00
yuyi
f31a3b4250 checker: check sumtype argument mismatch in generic methods (fix #16340 part2) (#16403) 2022-11-13 11:58:53 +03:00
yuyi
e8e75251b4 vweb: change optional to result in vweb_test (#16412) 2022-11-13 11:57:35 +03:00
Taegon Kim
b54f9c2949 parser: fix attributes with optional or result types (#16401) 2022-11-12 18:35:01 +03:00
kahsa
9a8602ff03 doc: improve types order (#16399) 2022-11-12 11:42:30 +02:00
kahsa
46f1b20bbc doc: split TOC into two rows (#16397) 2022-11-12 10:06:10 +02:00
Junko
5bb058e35b gg: revamp the Context pipeline for more effects, implement an additive effect (#16394) 2022-11-12 09:39:18 +02:00
kahsa
7d31473523 doc: add links (#16398) 2022-11-12 09:35:35 +02:00
Delyan Angelov
12f01318c2 v.live, cgen: enable using [live] in modules too (monitor used .v files for changes, not just the top level one) (#16396) 2022-11-11 22:06:42 +02:00
yuyi
c9ce5f89c7 builtin: fix f32.str() (#16391) 2022-11-11 13:56:45 +02:00
Delyan Angelov
c1a44efc78 tests: ensure that const loading is stressed in live_test.v, to prevent -live regressions for more complex examples like bounce.v 2022-11-11 10:45:54 +02:00
Delyan Angelov
e9fac05775 cgen: fix v -cc tcc -live run examples/hot_reload/graph.v too 2022-11-11 10:20:18 +02:00
Delyan Angelov
202f9574ec cgen: fix v -live -cc gcc examples/hot_reload/graph.v 2022-11-11 10:20:17 +02:00
shove
3a85955d22 all: rollback to old interpolation (step 4) (#16383) 2022-11-11 11:06:01 +03:00
yuyi
993e21e85b checker: check fntype mismatch of struct field init (fix #16372) (#16381) 2022-11-10 20:19:19 +02:00
yuyi
196b01aef7 all: minor cleanup of optional and result (#16382) 2022-11-10 20:14:20 +02:00
shove
26d643fc5d all: rollback to old interpolation (step 3) (#16380) 2022-11-10 15:05:34 +03:00
Delyan Angelov
bbae7a705f checker: fix incomplete implicit ast.CastExpr{} replacements 2022-11-10 13:59:22 +02:00
Delyan Angelov
7543b769ad checker: allow for all.children := { "abc": rect, "def": rectangle()}, where children is map[string]Widget, without needing explicit casts for all the map values 2022-11-10 13:59:21 +02:00
yuyi
46921480fc comptime: fix embed file with variable argument (fix #16360) (#16375) 2022-11-10 04:09:51 +02:00
Swastik Baranwal
bbd0603b41 checker: add check for unknown generic types in type alias decl (#16377) 2022-11-10 04:08:00 +02:00
Dominik Pytlewski
2634b99769 sqlite: expose SQLite's VFS layer (#16359) 2022-11-09 19:57:06 +02:00
yuyi
7e000bb6ae embed_file: correct test file name (#16376) 2022-11-09 19:55:51 +02:00
shove
a199a9afab all: rollback to old interpolation (step 2) (#16373) 2022-11-09 17:37:27 +03:00
shove
dd5f6186a1 all: rollback to old interpolation (step 1) (#16370) 2022-11-09 11:57:54 +03:00
Swastik Baranwal
7830597b66 checker: add check for multi level fn aliases (#16361) 2022-11-09 10:36:39 +02:00
Taegon Kim
ce79c9c876 checker: extract valid_comptime_ constants into v.checker.constants (#16371) 2022-11-09 10:07:21 +02:00
Roy Ivy III
a07f77ac52 make: add 'rebuild' target (clean and reset sub-repos, then rebuild V) (#16357) 2022-11-08 17:51:29 +03:00
yuyi
c7d0f0561e scanner: fix new string interpolation - nested quotes (#16345) 2022-11-08 17:51:02 +03:00
Taegon Kim
bc30608e92 checker: always trigger error for anon fns without a body block (#16358) 2022-11-08 15:50:59 +02:00
yuyi
1d04b71c91 cgen: fix generic sumtype auto str (#16355) 2022-11-08 10:49:09 +02:00
Taegon Kim
dc9997f58c fmt: fix - v fmt transforms compile time options in some cases (#16351) 2022-11-08 08:05:48 +02:00
Delyan Angelov
5f33585edf tools: add support for VSELF_SHOULD_FAIL to v self, in order to make testing all v up failure modes easier. 2022-11-07 12:36:30 +02:00
Roy Ivy III
c015f15d8d make.bat: fix use of make.bat from v up (#16348)
* .editorconfig: fix EOL for BAT files

* make.bat: fix use of `make.bat` from `v up`

- use move semantics, instead of replace, for `v` executable updates
- fixes [#16184](https://github.com/vlang/v/issues/16184)

# [why]

`v up` updates the executable by directly calling `make.bat`, awaiting
the result, which keeps an open file handle to it's own executable file.
`make.bat` compiles and, crucially, attempts to directly replace that
`v` executable. But, in WinOS, files with open file handles cannot be
deleted/replaced, so the `make` then fails. The other key point is that,
although WinOS files with open file handles can't be deleted/replaced,
they _can be moved/renamed_.

Thus, the technique that most self-updating WinOS executables use is to
move the current executable to some alternate name (ie, *v_old.exe*) and
then move the newly updated executable to the original location (ie,
*v.exe*). The next invocation of the "original" executable will then run
the updated version.

Note, this technique also works correctly for direct invocations of `make.bat`.
2022-11-07 08:48:08 +02:00
pancake
407bb6641f cgen: fix #16326 -cstrict with $embed_file (#16343) 2022-11-06 15:47:06 +02:00
Delyan Angelov
5638005b17 README: fix Termux instructions (add libexecinfo too) 2022-11-06 15:09:29 +02:00
Delyan Angelov
040bcd9141 README: add a section to clarify the installation process on Termux 2022-11-06 15:04:37 +02:00
yuyi
25b8ae2189 parser: minor cleanup in comptime.v (#16338) 2022-11-06 08:23:28 +03:00
pancake
e3fed4c3eb v.pkgconfig: fix infinite recursion bug when parsing dependencies (#16342) 2022-11-06 08:22:50 +03:00
Swastik Baranwal
ca484430e0 checker: check int overflow for const vars (#16332) 2022-11-06 08:22:28 +03:00
yuyi
d701cf561c scanner: fix new string interpolation: print('{n:10}') (fix #16321) (#16325) 2022-11-06 08:20:21 +03:00
Delyan Angelov
056f1b7c06 parser: improve error message for fn (a Foo<Foo<T>>) baz(){} 2022-11-05 19:58:22 +02:00
Delyan Angelov
27d8f2371d ci: fix go->spawn in the examples in vlib/context/README.md too 2022-11-05 14:02:24 +02:00
Delyan Angelov
bf00e9bdb8 tests: fix vlib/v/fmt/tests/*_expected.vv files too 2022-11-05 11:30:49 +02:00
Alexander Medvednikov
02acb8433c tests: fix keep tests with spawn 2022-11-05 12:13:20 +03:00
Delyan Angelov
9f2ab9aad6 ci: fix long line in doc/docs.md 2022-11-05 10:57:13 +02:00
Delyan Angelov
3e02f3b2b1 docs: put the short installation instructions directly in doc/docs.md too 2022-11-05 10:54:26 +02:00
Alexander Medvednikov
5b44da5ddb doc: replace go with spawn 2022-11-05 10:50:37 +03:00
Alexander Medvednikov
e81e0ac708 fmt: replace go with spawn 2022-11-05 10:46:40 +03:00
Alexander Medvednikov
a082328e40 parser: make spawn behave like go 2022-11-05 10:41:30 +03:00
Alexander Medvednikov
141c404d45 all: new keyword "spawn" 2022-11-05 09:43:38 +03:00
Delyan Angelov
b52b8429d4 vfmt: implement support for // vfmt off and // vfmt on, with it, v fmt -w . now works. (#16335) 2022-11-05 09:08:01 +03:00
yuyi
131d07aede parser: fix embed file to_string() in if guard (#16334) 2022-11-05 09:05:38 +03:00
Ted Stoychev
e1896ffd5b tutorials: fix a broken link (#16333) 2022-11-05 08:13:00 +03:00
Ted Stoychev
5933ab7158 docs: add syntax highlighting to a code snippet in the tutorials (#16331) 2022-11-04 17:01:25 +02:00
Delyan Angelov
4cabf709e1 tools: add support for a |``v shared| markdown code tag, for illustrating code examples starting with module not_main` 2022-11-04 15:35:25 +02:00
Delyan Angelov
2dffb04650 ci: fix formatting of cmd/tools/vtest-cleancode.v after resolving conflicts 2022-11-04 15:12:46 +02:00
Delyan Angelov
7f91db695c examples, tests: small formatting cleanup in cube_glsl.v , remove already fixed skips in v test-cleancode, before // vfmt off and // vfmt on 2022-11-04 14:48:20 +02:00
kahsa
fa7ff09370 doc: move Struct update syntax to the Struct section (#16305) 2022-11-04 09:01:51 +02:00
kahsa
3061859f25 doc: move the Parameter evaluation order section before References (#16306) 2022-11-04 08:57:40 +02:00
kahsa
cb5c6b605b doc: fix match heading and add ref field link (#16316) 2022-11-04 08:31:24 +02:00
penguindark
eb0c46e13a regex: fix for last group with OR inside (#16324) 2022-11-04 08:19:33 +02:00
yuyi
fd4045931a scanner: fix the new string interpolation - println('{s == 'hello'}') (fix #16318) (#16319)
* scanner: fix the new string interpolation - println('{s == 'hello'}')

* fix vlib/v/eval/gen/infix_gen.v
2022-11-03 23:06:11 +02:00
shove
0e8d148fe7 checker: give a checker error message on print(1), print(2) (fix #16311) (#16314) 2022-11-03 17:28:59 +02:00
Taegon Kim
962d0babdc js: fix match true {} in the js backend (#16317) 2022-11-03 17:25:45 +02:00
kahsa
4e02cd8721 doc: move match next to if (#16304) 2022-11-03 14:17:02 +02:00
yuyi
a979b3aab8 scanner: fix new string interpolation - print('{a}{{b}}') (#16309) 2022-11-03 14:04:41 +02:00
kahsa
9de92eb391 doc: add more links (#16303) 2022-11-03 13:36:39 +02:00
kahsa
fa3019195c doc: improve toc (#16302) 2022-11-03 13:34:05 +02:00
shove
fa4a45d37f all: make fmt support two kinds of interpolation at the same time. (#16308) 2022-11-03 13:32:07 +02:00
shove
5c7ceb16dd checker: fix the check of types not implemented by interfaces in infix key_is and not_is (fix #16282 #16298) (#16284) 2022-11-03 12:18:30 +02:00
Taegon Kim
14f90b1196 cgen: fix compile time reflection for method types (.typ was always 0) (#16310) 2022-11-03 12:16:01 +02:00
Delyan Angelov
f427a5241a os,tools: add os.vtmp_dir()
Use it to consistently place all temporary files created by tests in a overridable folder specific to the user, that is easy to cleanup later.

NOTE: os.temp_dir() on macos returns `/tmp`, and using `/tmp/v` is a problem when multiple unix users are trying to access/create/write to it.
2022-11-03 10:19:51 +02:00
kahsa
509f5c7db3 doc: fix links to attributes (#16301) 2022-11-03 07:02:01 +02:00
kahsa
1ecf7c6e41 doc: fix function heading (#16307) 2022-11-03 06:38:07 +02:00
shove
dddcf423db all: replace x[x.len-1] with x.last() (#16296) 2022-11-02 21:08:33 +02:00
JalonSolov
d11baa691c v: update the .gitattributes/.gitignore files generated by v init (#16292) 2022-11-02 20:41:12 +02:00
Taegon Kim
d4c83f62b2 doc: fix a broken example in json2's README.md (#16293) 2022-11-02 19:29:43 +02:00
shove
5fe4888874 parser: fix raw string as map keys (fix #16285) (#16289) 2022-11-02 16:04:22 +02:00
Spydr
075c025999 native: don't generate duplicate strings (#16281) 2022-11-02 15:48:25 +02:00
shove
0fa6f60fac cgen: fix call method with an empty args on an interface with variadic (fix #16286) (#16290) 2022-11-02 15:45:39 +02:00
yuyi
4e05e07b94 checker: check undefined ident in closure anon fn (fix #16274) (#16278) 2022-11-02 15:41:44 +02:00
kahsa
0510a69bea doc: categorize the advanced topic section (#16276) 2022-11-02 15:33:29 +02:00
yuyi
54b6b43922 cgen: fix dump(none) (#16287) 2022-11-02 14:21:28 +02:00
Delyan Angelov
7bd00b7580 tools: make fast_job.v more verbose and robust to compilation failures in fast.v, and to what compiler exactly was used to compile fast_job.v itself. 2022-11-02 13:26:12 +02:00
Delyan Angelov
82dc9ca434 tools: make fast.v results more robust to AWS spikes (increase samples, discard the top few) 2022-11-02 13:03:30 +02:00
Alexander Medvednikov
38291fd292 changelog: minor fixes 2022-11-02 12:50:16 +03:00
Alexander Medvednikov
0aa2c63afd changelog: 0.3.2 2022-11-02 10:08:21 +03:00
Alexander Medvednikov
33bd7decdc readme: update links 2022-11-02 08:26:57 +03:00
shove
e5d1881e1a checker: fix multiple pointer check of fn and method args (fix #16261 #16262 #16263) (#16275) 2022-11-01 19:05:34 +02:00
Hitalo Souza
d2902e700f examples: show how to use a before_request method for the multi-route examples, be more informative about DB creation problems (#16279) 2022-11-01 19:02:07 +02:00
JalonSolov
0c03ebb7a4 .gitignore: ignore Intellij items (#16280) 2022-11-01 18:51:46 +02:00
Delyan Angelov
31adc65dd6 examples: mention -d no_backtrace in examples/call_v_from_python/README.md 2022-11-01 18:16:30 +02:00
Delyan Angelov
968435fca6 toml: clearly mark the workaround [manualfree] tags with [autofree_bug; manualfree], so they can be found/removed when -autofree is fixed 2022-11-01 18:08:38 +02:00
Delyan Angelov
ffd9b9bae1 ci,toml: add a workaround for buggy -autofree (skip -autofree compilation for some of the toml functions, that prevent VED to compile cleanly on the CI) 2022-11-01 17:52:41 +02:00
Delyan Angelov
bd7c86a9d4 tools: make fast_job.v more informative on updates 2022-11-01 16:12:36 +02:00
Delyan Angelov
1868b101a5 tools: fix commit message cell border in fast.vlang.io 2022-11-01 16:05:50 +02:00
Delyan Angelov
32ce3d9149 tools: make fast_job.v more robust 2022-11-01 15:49:23 +02:00
Delyan Angelov
edb3f1df32 tools: fix table wrapping in fast.vlang.io, use <th> cells for the heading 2022-11-01 15:13:09 +02:00
vlang-bot
9cdec87255 tools: add more logging for fast_job.v, to ease maintainance 2022-11-01 10:54:12 +00:00
penguindark
362adfae3a regex: fix a bug for CC token not correctly parsed in groups (#16272) 2022-11-01 08:58:29 +02:00
JalonSolov
47a10f3181 doc: update ssl section in the main README.md (#16273) 2022-11-01 07:28:39 +02:00
Alexander Medvednikov
135b1ccb14 V 0.3.2 2022-11-01 05:41:13 +03:00
Spydr
1b721250e0 native: enable printing for all supported expressions (#16270) 2022-10-31 17:43:02 +02:00
yuyi
339bd0c4b5 checker: check fn type mismatch of return result type fn (#16269) 2022-10-31 14:05:43 +02:00
shove
c3e209a634 scanner: prevent resolving to nested interpolation (fix #16240) (#16259) 2022-10-31 10:47:32 +02:00
Delyan Angelov
4a7a4b9ec5 docs: improve the package related sections; describe VMODULES. 2022-10-31 10:13:18 +02:00
Mykhailo
cd4a999e80 examples: add custom_error.v, that shows how to match over possible errors (#16265) 2022-10-31 09:56:41 +02:00
yuyi
0390a7a988 cgen: fix return match expr of sumtype result (#16264) 2022-10-30 20:26:33 +02:00
yuyi
64cbadc6f1 scanner: fix new string interpolation println('{a}{b}{c}{d}') (#16258) 2022-10-30 20:18:31 +02:00
Delyan Angelov
914f03a1a2 doc: document the -no-bounds-checking option in v help build 2022-10-30 15:05:02 +02:00
Delyan Angelov
9edb48571f pref,cgen: support -no-bounds-checking, instead of -d no_bounds_checking, and make it enable direct_array_access for all fns/methods. 2022-10-30 14:39:45 +02:00
lemon
54b623743d native, checker: cast float_literal to f32 explicitly in code gen (#16254) 2022-10-30 10:31:18 +02:00
shove
93d765eeee cgen: fix dump() multi ptr (fix #16247) (#16251) 2022-10-29 10:07:28 +03:00
Swastik Baranwal
a988ef3474 checker: add check for mut ident but not if mut ident is for interfaces (#16214) 2022-10-29 06:36:44 +03:00
yuyi
ee782e9119 checker: fix return error with multi_return optional (#16250) 2022-10-29 06:34:45 +03:00
Hitalo Souza
78c4b9a7bb doc: one single file for vweb (#16248) 2022-10-29 06:33:48 +03:00
Delyan Angelov
02c3af2432 all: add support for enum Xyz as u64 { + tests (#16246) 2022-10-29 06:32:20 +03:00
Delyan Angelov
4564a47fbc .gitignore: ignore Visual Studio's .vs/ folder 2022-10-28 22:40:47 +03:00
Grantley Cullar
21d18b0792 doc: fix typos (#16239) 2022-10-28 22:27:38 +03:00
Delyan Angelov
a0a055cc4c ci: fix failures after c6158e4 2022-10-28 21:52:52 +03:00
Alexander Medvednikov
c6158e4519 all: remove unnecessary IError() casts 2022-10-28 19:08:30 +03:00
yuyi
daa2f90023 scanner: fix and resotre string interpolation tests (#16242) 2022-10-28 18:39:32 +03:00
shove
5daa38fdb1 util: fix smart_quote, so that v -cstrict file.v works with println('\\$') (fix #16230) (#16233) 2022-10-28 12:41:13 +03:00
StunxFS
ef1696b3e1 v.util: add path_styled_for_error_messages/1 (#16219) 2022-10-28 11:27:00 +03:00
shove
af56719f9d fmt: fix compiler_error('...') broken by fmt (fix #16218) (#16231) 2022-10-28 06:48:09 +03:00
StunxFS
219079e3a6 v.eval: consistency in commit hash shown on panic (#16227) 2022-10-28 06:47:50 +03:00
shove
c5ee33b7aa cgen: fix comparing struct with pointers to interface values (fix #16074) (#16215) 2022-10-28 06:47:31 +03:00
yuyi
992106c6f7 tests: fix ci errors temporary (#16237) 2022-10-28 06:46:20 +03:00
yuyi
0ca5b1f6ff cgen: fix $tmpl() in returning match expr (fix #16109, fix #16124) (#16229) 2022-10-27 18:03:27 +03:00
Alexander Medvednikov
e356a74a4c tests: disable a single string interpolation test for now 2022-10-27 18:02:25 +03:00
Alexander Medvednikov
cc58d6a919 all: string interpolation fixes 2022-10-27 17:52:30 +03:00
kahsa
d653716292 doc: add global variables link (#16228) 2022-10-27 13:09:05 +03:00
Alexander Medvednikov
098db89b85 encoding.csv: remove unnecessary IError() cast 2022-10-27 11:30:08 +03:00
Alexander Medvednikov
c9934672c4 http: fix request_test.v 2022-10-27 11:28:44 +03:00
Alexander Medvednikov
a134c09718 os: fix font.v compilation 2022-10-27 11:13:43 +03:00
Alexander Medvednikov
e1ffc76efd tests: fix some interpolation tests 2022-10-27 11:12:15 +03:00
Alexander Medvednikov
604f19adba scanner: : str inter fix 2022-10-27 11:08:32 +03:00
Alexander Medvednikov
18c7da9a5e all: new string interpolation "hello {name}!" 2022-10-27 11:01:01 +03:00
StunxFS
e6fad82b87 v.eval: support unsafe expr (#16224) 2022-10-27 10:38:57 +03:00
kahsa
ce2c732db8 doc: move the Attributes subsection at the start of its parent section (#16183) 2022-10-26 23:28:37 +03:00
Delyan Angelov
41c85661ef fix quadratic execution of VAUTOFIX=1 v check-md . when a long .md file has many examples, that have to be corrected. 2022-10-26 22:47:58 +03:00
Delyan Angelov
007430ef2b tools: support VAUTOFIX=1 v check-md vlib/term/README.md for fixing unformatted examples without manual edits 2022-10-26 21:51:10 +03:00
yuyi
064e35fbc4 parser: fix $tmpl with single quotes (fix #16154) (#16216) 2022-10-26 19:38:08 +03:00
boons
a19a4ba299 examples: add a tiny brainvuck interpreter (#16213) 2022-10-26 19:31:15 +03:00
yuyi
992b502198 db, json, time, term: change optional to result (#16201) 2022-10-26 11:26:28 +03:00
lemon
2a7420f572 native: add initial support for f32/f64 (#16210) 2022-10-26 10:37:46 +03:00
shove
fef4dd94e9 ast, checker, cgen: enable unsafe { nil } with reference to interface fields in structs (fix #16198) (#16199) 2022-10-26 09:39:23 +03:00
yuyi
53c6e46a51 parser: correct comptime path not found error position (fix #16189) (#16209) 2022-10-26 09:33:58 +03:00
Alexander Medvednikov
572e26204e changelog: some 0.3.2 features 2022-10-26 02:34:54 +03:00
Delyan Angelov
b2ab7a333b transformer: improve -trace-calls output, enable tracing of builtin fns, show elapsed ns and used stack size (#16205)
Make it easier to change later, by splitting the tracing call into its own `v.trace_calls` module, so that it can be iterated upon without changing the compiler itself.
2022-10-25 20:56:12 +03:00
yuyi
03bef24456 checker: fix returning embedded error result (#16208) 2022-10-25 18:17:48 +03:00
StunxFS
76606598c3 cleanup: delete database.db in project root folder (#16190) 2022-10-25 10:43:17 +03:00
kahsa
779cc33825 doc: rename module to package, when it comes to all VPM commands like v install etc (#16180) 2022-10-24 18:00:55 +03:00
kahsa
d3fcb6bca0 doc: add a subheading for creating new modules (#16188) 2022-10-24 17:56:34 +03:00
Delyan Angelov
00ec41e0a9 ci: small fix for docs.md 2022-10-24 17:32:01 +03:00
Alexander Medvednikov
690b2c0b9d doc: more Result fixes 2022-10-24 16:26:19 +03:00
Alexander Medvednikov
2c9e890c3d doc: document the Option/Result split 2022-10-24 16:11:20 +03:00
yuyi
4aa4af4afb cgen: fix vweb app route methods filtering (#16186) 2022-10-24 12:51:20 +03:00
kahsa
26c737b6db doc: move goto section under statements (#16179) 2022-10-24 12:09:14 +03:00
shove
701586fa84 checker, cgen: enable calls to methods of the parent element array, when an array element is an alias (fix #16169) (#16187) 2022-10-24 12:02:24 +03:00
Swastik Baranwal
f25dfa9d8c checker: add error for unwrapped result in infix expr (#16175) 2022-10-24 11:53:35 +03:00
yuyi
48f43f11ea all: change optional to result in vlib/v. (#16177) 2022-10-24 11:51:20 +03:00
Ikko Ashimine
26986104f9 cgen: fix typos (#16174) 2022-10-23 22:28:58 +03:00
yuyi
7b8044b8c4 cgen: fix using 'array' name variable in array_init (#16168) 2022-10-23 22:23:15 +03:00
Wertzui123
340611c298 net: add a net.tcp_socket_from_handle_raw function (#16167) 2022-10-23 22:21:46 +03:00
kahsa
158fd5c249 doc: TOC add missing h3 (#16170) 2022-10-23 22:17:20 +03:00
kahsa
235bd87db5 doc: improve TOC (#16166) 2022-10-23 17:31:50 +03:00
Delyan Angelov
9241b5572b net.http: skip network timeouts on socket accept in the main http.Server loop 2022-10-23 17:08:27 +03:00
kahsa
00bd7b621d doc: minor fix (#16164) 2022-10-23 14:30:59 +03:00
kahsa
2d08c7b629 doc: fix headings under Grobal Variables (#16162) 2022-10-23 14:21:25 +03:00
yuyi
3f035205b3 cgen: fix return result in or block (#16158) 2022-10-23 13:11:11 +03:00
kahsa
33b2b4c6a1 doc: add link to template.md (#16155) 2022-10-23 13:07:22 +03:00
shove
721dbec2e4 checker: fix missed check on the initialization of result struct fields (fix #16152) (#16153) 2022-10-22 20:02:11 +03:00
Spydr
83338e044a native: fix small issues with compile-time conditionals (#16149) 2022-10-22 19:56:19 +03:00
shove
b8b2b4ad0a checker: fix the pos information in the warning message, when the label is not used (fix #16146) (#16148) 2022-10-22 19:26:38 +03:00
Hitalo Souza
3d4ffe8f28 examples: unskip vweb_orm_jwt from building, since it is not working directly with mysql anymore (#15671) 2022-10-22 19:12:54 +03:00
Delyan Angelov
a23e06184d checker: fix taking a closure of x, where x may be coming from a non trivial parent scope, like for x in y { or x,y := multi() (fix #16141) (#16147) 2022-10-22 15:53:27 +03:00
l-m
a139bed785 builtin: add string.trim_indexes method, that can be used in string.trim, but also separately from it (#16144) 2022-10-22 12:56:05 +03:00
yuyi
b6faf82911 parser: minor optimization in sql_expr() (#16145) 2022-10-22 12:11:45 +03:00
yuyi
9288c75c94 parser: simplify and cleanup check_undefined_variable() (#16140) 2022-10-22 11:26:21 +03:00
shove
e863191ff6 checker: fix generic information is lost of the map built-in method call (fix #16077) (#16134) 2022-10-21 23:07:05 +03:00
yuyi
ab78d5a7ba parser: check undefined variable in if guard (#16138) 2022-10-21 22:48:59 +03:00
Delyan Angelov
b40f1828b2 ci: re-enable building VEX in v_apps_and_modules_compile.yml 2022-10-21 10:44:59 +03:00
Makhnev Petr
2e8b9e3b92 v fmt: fix extra space for anon struct (#16131) 2022-10-21 10:38:19 +03:00
bogen85
c684dd8c9b log: mark log.fatal as [noreturn] (#16129) 2022-10-21 10:33:49 +03:00
yuyi
51f4d99399 all: change optional to result in most of the libraries (#16123) 2022-10-20 22:14:33 +03:00
yuyi
0d368562f4 cgen: minor optimization and cleanup in match_expr_sumtype() (#16126) 2022-10-20 20:36:56 +03:00
locriacyber
a3b050aced vrepl: add support for Home and End keys (#16116) 2022-10-20 20:07:57 +03:00
yuyi
f8a28b5a5d checker: check generic method called with a variadic argument mismatch (fix #16106) (#16110) 2022-10-20 15:28:30 +03:00
shove
07310d850d ast, cgen: fix wrong name and cname, when array and fixed array elements have optional (fix #16099) (#16122) 2022-10-20 14:17:57 +03:00
Delyan Angelov
2083e6b04c os: cleanup APIs returning !bool to either return ! or bool (#16111) 2022-10-20 13:56:06 +03:00
Swastik Baranwal
ac63fa1b11 parser: improve error for fixed array, when it has len and cap attributes in the initialisation list (#16120) 2022-10-20 13:36:13 +03:00
Delyan Angelov
ffcdac4201 ci: fix v_tictactoe.out after 05a1c3e 2022-10-19 22:33:10 +03:00
Delyan Angelov
05a1c3e8a3 parser,ci: fix regression after eda65ad in the VLS tests 2022-10-19 22:29:08 +03:00
yuyi
612faac0f0 all: change index expr returning optional to result too (#16097) 2022-10-19 21:04:16 +03:00
Delyan Angelov
eda65ad660 parser,checker,builder: make the checker more robust with -check over files with syntax/parsing errors 2022-10-19 18:14:58 +03:00
Delyan Angelov
d7813965d5 tools: fix os.chmod call (use octal permissions) in v ls 2022-10-19 15:38:06 +03:00
Delyan Angelov
7f294c8278 tests: use _test.v for the postfix of some test files, that were missing it 2022-10-19 12:38:58 +03:00
Grantley Cullar
37b03e57b4 tutorials: fix typos (#16098) 2022-10-19 12:20:11 +03:00
Makhnev Petr
2f3c4c6d91 v fmt: fix extra space for lock/rlock without expressions (#16103) 2022-10-19 12:18:21 +03:00
yuyi
026fccd373 cgen: fix match expr with last aggregate branch (#16101) 2022-10-19 11:49:39 +03:00
yuyi
117c829a97 vtest-self: add skipping ssl tests on windows (#16107) 2022-10-19 11:03:29 +03:00
Alexander di Chiara
e3379bca97 datatypes: add quadtree, add its demo to examples/ (#16087) 2022-10-18 18:02:44 +03:00
StunxFS
cc9b754801 vlib: delete unused darwin module (#16093) 2022-10-18 18:01:25 +03:00
yuyi
9242d4b79b json2: minor cleanup in README.md (#16096) 2022-10-18 18:00:14 +03:00
Delyan Angelov
71bff213ef builtin: make the C. WIN32 API declarations more precise, to catch errors earlier (#16090) 2022-10-17 20:23:33 +03:00
yuyi
126c4c5751 builtin,math: fix math.min_i64.str() (fix #16086) (#16089) 2022-10-17 19:36:46 +03:00
yuyi
556244576d checker: check unused last expression in if (fix #16084) (#16088) 2022-10-17 18:15:01 +03:00
Subhomoy Haldar
43b9a716c5 builtin,strconv: append ".0", to float string representations, to ensure clarity (#16079) 2022-10-17 15:41:07 +03:00
Delyan Angelov
29b1796791 ci: add more skips for different CI jobs 2022-10-17 10:24:01 +03:00
Delyan Angelov
7fb2718609 ci: only run openssl_compiles_test.v on !windows 2022-10-16 23:15:00 +03:00
Delyan Angelov
7ff7e540b9 ci: more ? -> ! fixes 2022-10-16 22:57:38 +03:00
Delyan Angelov
7302d8c4a8 examples: improve the examples/call_v_from_python with Python showing the result of the calculation done on the V side 2022-10-16 22:48:00 +03:00
Delyan Angelov
409a4f33a1 tools: add report_v_module_folders_without_tests.v . Use it to discover other modules without _test.v files. Add simple ones, to ensure CI can find more breakage on future wide changes to vlib/ 2022-10-16 22:40:17 +03:00
Delyan Angelov
17800b4bca ci: fix net.openssl, ensure that it is at least compiled, to avoid future regressions on sweeping vlib changes 2022-10-16 20:59:04 +03:00
Delyan Angelov
603319e30b .gitignore: ignore vold/vnew (ensure that artefacts used for benchmarking before/after changes are not commited) 2022-10-16 20:44:07 +03:00
Delyan Angelov
95d2c58148 checker: produce more informative error messages on ~,!,-,<- operator type mismatches 2022-10-16 20:27:40 +03:00
Delyan Angelov
3d2e251bf2 transformer: fix precalculations of simple expressions involving floating literals, with -prod (fix VSL tests with -prod) 2022-10-16 20:23:41 +03:00
Delyan Angelov
d857e97d8c strconv: enable VTL compilation with -prod (remove deprecation for strconv.v_sprintf temporarily) 2022-10-16 17:43:52 +03:00
Delyan Angelov
78e9362d74 ci: workaround for a VLS failing test, that stops symbol registration after the first fn()! { 2022-10-16 13:38:20 +03:00
Delyan Angelov
c02974622f tests: add checks_for_operator_overrides_should_happen_on_the_concrete_types_when_using_generics_test.v 2022-10-16 12:57:34 +03:00
Delyan Angelov
710c2b22da parser: fix infinite loop for type Handler = fn (test string) string without newline at the end 2022-10-16 10:42:53 +03:00
yuyi
f6844e9766 all: change optional to result of io (#16075) 2022-10-16 09:28:57 +03:00
shove
6e46933c55 cgen: fix or {} handling, when waiting for a single go thread, of a function returning !Type (fix #16065) (#16073) 2022-10-14 19:54:13 +03:00
Delyan Angelov
49c12e4d1c cgen: fix ./tracev examples/hello_world.v 2022-10-14 19:27:40 +03:00
shove
6bf2ad1ff0 cgen: fix missing * of optional non-ref structs (fix: #16070) (#16071) 2022-10-14 10:34:42 +03:00
yuyi
39d2aa71df checker: check generic closure fn declaration (#16069) 2022-10-14 10:24:10 +03:00
zztkm
3e4cfc7343 os: add os.to_slash and os.from_slash functions (#16055) 2022-10-14 10:22:36 +03:00
Subhomoy Haldar
09e23e3ed6 rand: add rand.element and prng.element functions with unit test (#16068) 2022-10-14 06:54:02 +03:00
Swastik Baranwal
f7f0e0b5dc v doc: remove int_literal and float_literal from syntax highlighting, since they are internal types (#16066) 2022-10-13 20:49:34 +03:00
shove
aabda5a525 checker: allow get_ref() or { unsafe{nil} }, as well as fn get_ref() ?&Type { return unsafe { nil } } (fix: #16062) (#16063) 2022-10-13 19:49:10 +03:00
shove
51a9e89c4a ast: disallow threads << go fn()?{} and threads << go fn()!{} (fix #16061) (#16064) 2022-10-13 19:37:27 +03:00
yuyi
f0108323d1 cgen: fix generic closure fn direct call (#16057) 2022-10-13 18:06:34 +03:00
shove
e3e8bb2f88 cgen: remove spaces in the generated name for ?&C.struct (fix #16058) (#16059) 2022-10-13 18:05:16 +03:00
yuyi
bfbfe78366 cgen: fix assigning optional of multi_return with heap (#16049) 2022-10-13 13:07:52 +03:00
shove
213a094680 ast: fix missing 'optional' and 'result' in type name and cname of map (#16047) 2022-10-13 10:38:02 +03:00
Swastik Baranwal
3e33f4a11d checker: disallow nil assignment on non pointer struct fields (#16056) 2022-10-13 10:36:59 +03:00
yuyi
fb3d093e01 builtin: remove opt_ok2() (part 2) (#16054) 2022-10-13 10:35:41 +03:00
shove
4fbb29a2c0 checker: disallow x := fncallexpr() or { X{} } , when the fn result type is ?&X (fix #16050) (#16051) 2022-10-12 22:49:30 +03:00
yuyi
6bdd11e53b checker: check error for fn call with extra parenthesis (#16052) 2022-10-12 22:43:59 +03:00
yuyi
211cb2af7b cgen: remove opt_ok2() part 1 (#16048) 2022-10-12 17:20:41 +03:00
yuyi
c590c8250e cgen: fix fn with optional of multi_return (#16046) 2022-10-12 09:44:15 +03:00
Delyan Angelov
7f2d731d19 cgen: fix dump(c_struct), where c_struct has fields of type &&char 2022-10-12 09:00:16 +03:00
shove
9569c0504c cgen: fix map with optional or result on return (#16044) 2022-10-12 07:54:29 +03:00
Rasheed
12d3664a09 builtin: add a declaration for C.putchar (#16037) 2022-10-11 20:53:12 +03:00
shove
4c0ea67137 cgen: fix map with optional or result (fix #15972) (#16036) 2022-10-11 16:33:19 +03:00
Swastik Baranwal
05fc7d3a72 checker: disallow function cast outside unsafe (#16030) 2022-10-11 15:46:35 +03:00
Wertzui123
5047058595 stbi: fix memory leak from stbi.load/1 with GC (#16028) 2022-10-11 15:19:36 +03:00
yuyi
34f233c93f cgen: fix generic struct init with generic cast (#16035) 2022-10-11 15:00:02 +03:00
yuyi
dab1c8a71d all: clean up optional and result handling (#16034) 2022-10-11 09:23:57 +03:00
shove
34d115d883 cgen: fix wrong when string attributes with quotes (fix #15194) (#16020) 2022-10-11 07:48:26 +03:00
shove
eebc82d83a fmt: fix wrong processing of quotes, when formatting string literals (fix #16017) (#16018) 2022-10-10 21:19:34 +03:00
yuyi
8f3f717736 checker: check type mismatch of return match expr (#16019) 2022-10-10 19:41:55 +03:00
yuyi
89eb8358cf checker: fix fn returning ![]string called in main (#16023) 2022-10-10 19:41:24 +03:00
Thomas Peißl
0f229874a2 net.mbedtls: add explicit closing of the tcp connection in the shutdown method (#16027) 2022-10-10 19:30:58 +03:00
Delyan Angelov
82593338fa ci: fix v -usecache -o x cmd/v on macos 2022-10-10 16:01:04 +03:00
Delyan Angelov
14923123ad ci: skip const_fixed_array_containing_references_to_itself_test.v on windows-msvc 2022-10-10 13:30:35 +03:00
Delyan Angelov
d4e89de8fb ci: fix v -cstrict -cc gcc vlib/v/gen/native/macho_test.v 2022-10-10 13:28:18 +03:00
Delyan Angelov
2a4604b5f9 Revert "examples: fix viewer example (use the new stbi.load_from_memory_with_channels) (#16004)"
This reverts commit bce420c34d.
2022-10-10 11:37:36 +03:00
Delyan Angelov
fa20d797a5 Revert "examples: increase the window size of drag_n_drop.v a little (test CI)"
This reverts commit 8fc166d5a3.
2022-10-10 10:39:58 +03:00
Delyan Angelov
3c25f506ed Revert "stbi: fix loading image from memory (#15981); breaks UI's rectangle example on macos, probably others too"
This reverts commit 07d5612347.
2022-10-10 10:39:32 +03:00
Delyan Angelov
8fc166d5a3 examples: increase the window size of drag_n_drop.v a little (test CI) 2022-10-10 04:04:27 +03:00
Delyan Angelov
a7b2b3c70e ci: fix ci.yml (add the second missing required run: line to a task) 2022-10-10 03:48:20 +03:00
Delyan Angelov
ade8fdff69 vfmt: fix v -W ./cmd/tools/vfmt.v, (and v -W build-examples) 2022-10-10 03:44:11 +03:00
Delyan Angelov
a4e8b9cabe ci: fix ci.yml (add missing required run: line to a task) 2022-10-10 03:43:00 +03:00
Aftab Alam
345d4d60e5 readme: add hyperlink to the vlang.io site, to the logo image (#16014) 2022-10-10 02:53:33 +03:00
yuyi
32ab08287c checker: add a notice about skipping the generic route methods of vweb apps (#16013) 2022-10-10 02:50:10 +03:00
Niraj Kulkarni
553315b80c gx: add documentation for Color methods (#16010) 2022-10-10 02:47:55 +03:00
shove
8666ef43fd cgen: fix dependency order error between sumtype and fixed array type (fix #16003) (#16009) 2022-10-09 12:16:50 +03:00
ChAoS_UnItY
95f57e9206 builtin: deprecate array.reduce in favour of arrays.fold (#16001) 2022-10-09 10:29:50 +03:00
yuyi
fe6197fe2d fmt: remove comma inside map_init using multi_line (#16007) 2022-10-09 08:39:30 +03:00
shove
e2398cafd2 cgen: fix str() fails when the structure 'charptr' type field is nil (fix #15970) (#16002) 2022-10-09 08:33:45 +03:00
penguindark
bce420c34d examples: fix viewer example (use the new stbi.load_from_memory_with_channels) (#16004) 2022-10-09 08:30:02 +03:00
Delyan Angelov
54197121bc sokol.sapp: remove update_cursor from EventType, since it is no longer defined in Sokol, fixes examples/gg/drag_n_drop.v 2022-10-08 22:01:22 +03:00
shove
cd96a43030 fmt: fix unreasonable wrap after if in if very_long && condition { (fix #15635) (#15995) 2022-10-08 19:31:00 +03:00
yuyi
ce1ba2ad02 checker: check fn returning fn type mismatch (fix #15988) (#15997) 2022-10-08 19:28:41 +03:00
Swastik Baranwal
49aac93d87 checker: disallow literals on the left side of assignments (#15999) 2022-10-08 19:27:30 +03:00
yuyi
91e641a422 parser: fix map init with multi enum keys (fix #15965) (#15991) 2022-10-08 18:56:02 +03:00
Delyan Angelov
754c387d1b cgen,checker: support simple voidptr casts in consts, without delaying the initialisation to _vinit (#15996) 2022-10-08 13:14:26 +03:00
yuyi
272b3cf8c3 checker: check undefined operation of the generic infix expr (#15987) 2022-10-08 12:09:32 +03:00
yuyi
4eeb45b94e vpm: stop and output an error message after parsing the v.mod file failed (#15994) 2022-10-08 11:33:49 +03:00
Swastik Baranwal
267cd5569a vpm: replace println with eprintln, for printing error output (#15992) 2022-10-08 11:32:31 +03:00
locriacyber
07d5612347 stbi: fix loading image from memory (#15981) 2022-10-07 17:20:35 +03:00
yuyi
03f82d5f68 cgen: fix generic for_in using iteration (#15979) 2022-10-06 18:20:38 +03:00
yuyi
73e28ec523 checker: fix infering fn type using reference argument (#15978) 2022-10-06 17:25:02 +03:00
Delyan Angelov
88d69d7d54 cgen,pref,preludes: implement v -assert continues file_test.v (#15976) 2022-10-06 17:20:32 +03:00
Larpon
58bf2838c0 builder: exclude LDFLAGS in .o builds (#15977) 2022-10-06 17:18:48 +03:00
Joe Conigliaro
87a364ff24 cgen: remove condition no longer needed after #15944 2022-10-06 17:15:15 +11:00
Joe Conigliaro
3eff20c5fd checker,cgen: small optimizations for previous commit 2022-10-06 17:03:48 +11:00
Joe C
18f0040388 checker/gen/parser: varg with pointer type fix: #15943 (#15944) 2022-10-06 15:58:07 +11:00
yuyi
f0871b87a4 term: fix errors in input_windows.c.v (#15966) 2022-10-05 13:24:22 +03:00
yuyi
6ccdf89546 cgen: fix vweb using generic method (fix #15888) (#15963) 2022-10-05 13:23:47 +03:00
Alexander Medvednikov
46138a2841 cbuilder: more clear fn name 2022-10-05 08:51:52 +03:00
ChAoS_UnItY
acbfe88dd9 arrays, maps: cleanup comments and parameter names in function signatures (#15960) 2022-10-04 10:07:36 +03:00
kahsa
40cbd68272 sqlite: add a sqlite.is_error() helper (#15964) 2022-10-04 10:03:59 +03:00
Swastik Baranwal
267e26ba1d net: add unsafe block to int -> enum cast (#15961)
Fixes https://github.com/vlang/v/issues/15959
2022-10-03 21:56:06 +03:00
Spydr
6ac9552d39 native: support simple library calls (#15958) 2022-10-03 17:49:22 +03:00
Swastik Baranwal
9fc64de94b openssl: add unsafe blocks to int -> enum blocks (#15957) 2022-10-03 16:32:37 +03:00
shove
dc2ba1c33f ast, parser, fmt: fixed and optimized comments for 'for, for_c, for_in stmts' (fix: #15922) (#15950) 2022-10-03 10:45:11 +03:00
ChAoS_UnItY
ffaca82ff8 arrays, maps: add indexed variant of collection function and minor cleanup (#15948) 2022-10-03 10:42:36 +03:00
Spydr
5b59171a00 checker, native: Check arguments of native builtin functions (#15952) 2022-10-03 10:41:59 +03:00
Delyan Angelov
c655847dfb native: fix notices when building cmd/tools/builders/native_builder.v 2022-10-02 22:48:06 +03:00
Swastik Baranwal
b584e1df98 checker: allow EnumName(number) casts only inside unsafe{} blocks (#15932) 2022-10-02 22:39:11 +03:00
Spydr
7993f0bf39 native: support for compile-time conditionals (#15949) 2022-10-02 22:31:59 +03:00
Delyan Angelov
b83d0281e4 checker: make the "reference field must be initialised" warning more informative, fix clipboard (used by ui) 2022-10-02 16:24:15 +03:00
yuyi
b158da398b parser: fix checking for duplicate main functions (#15946) 2022-10-02 12:14:25 +03:00
Delyan Angelov
ed2960a20e sokol.sapp: fix compilation of gg apps with -prod (add typedef tags to Sokol's C struct declarations) 2022-10-02 12:10:35 +03:00
Delyan Angelov
35368b5721 checker: small cleanup in Checker.check_ref_fields_initialized 2022-10-02 12:10:35 +03:00
Delyan Angelov
eec126e26c vfmt: run v fmt -w vlib/v/gen/native/tests/ 2022-10-02 12:10:34 +03:00
ChAoS_UnItY
20f5eef2dc maps: add a maps module, with generic filter, flatten, invert, to_map, to_array, from_array functions (#15945) 2022-10-02 10:59:13 +03:00
Swastik Baranwal
8a38bc2324 fmt: keep volatile qualifier in global declarations (#15947) 2022-10-02 10:50:16 +03:00
lemon
a7ad64033e native: support assigning to struct fields (#15938) 2022-10-01 14:42:26 +03:00
shove
5dae5b2a92 checker: fix references for alias type, that could still be uninitalized (fix #15935) (#15940) 2022-10-01 14:40:55 +03:00
Delyan Angelov
17b07273aa cbuilder: remove forgotten dump(), simplify o_postfixes 2022-10-01 14:00:35 +03:00
Delyan Angelov
90599c7f85 cbuilder: fix hardcoded v_parallel for -parallel-cc, use a sync.pool for the compilation threads 2022-10-01 13:50:47 +03:00
yuyi
aa02a9cd3b checker: fix checking mismatch of the fn array decompose argument (#15934) 2022-10-01 13:25:24 +03:00
yuyi
f6a68003d3 ci,parser: fix error in v_parser_test.v (#15936) 2022-10-01 13:18:46 +03:00
ChAoS_UnItY
fe597b7172 encoding.utf8: add is_number (#15931) 2022-10-01 11:01:51 +03:00
Alexander Medvednikov
3d2588f101 cgen: parallel cc for much faster compilation using all CPU cores 2022-10-01 10:04:06 +03:00
yuyi
be7b0f1dc5 checker: check mismatch of the fn array decompose argument (#15929) 2022-10-01 06:50:28 +03:00
Spydr
43d0d0f322 native: skip linking when no library functions get called (#15930) 2022-10-01 06:47:16 +03:00
lemon
d78dfabfe0 native: support casting integer to/from enum values (#15928) 2022-09-30 15:53:17 +03:00
yuyi
d694a26f39 checker, cgen: fix go print (#15927) 2022-09-30 15:50:54 +03:00
shove
b6bbbcf2e7 cgen: fix error when defer inside comptime if {} else {} (fix #15891) (#15911) 2022-09-30 10:10:34 +03:00
yuyi
659bd1a428 ast, checker, cgen: fix generic fn/method with comptime for/if (fix #15905) (#15910) 2022-09-30 09:40:30 +10:00
shove
63578e63c6 fmt: fix comments between for and { is wrong (fix #15918) (#15919) 2022-09-29 15:26:27 +03:00
Tim Marston
711bb6def7 gg: rename Context.set_cfg() -> Context.set_text_cfg() (#15904) 2022-09-29 15:24:16 +03:00
Larpon
2d08950e4c changelog: add entry for #15912 no need for [console] on Windows (#15924) 2022-09-29 15:20:19 +03:00
Larpon
816e9319d7 cgen: remove the need for [console] for gg or ui programs on windows (#15912) 2022-09-29 15:02:50 +03:00
Mehmet Ali
79a473f8ec vweb: fix a typo in the README.md (#15913)
* Fix typo

* Update vlib/vweb/README.md

Co-authored-by: JalonSolov <JalonSolov@gmail.com>

Co-authored-by: Delyan Angelov <delian66@gmail.com>
Co-authored-by: JalonSolov <JalonSolov@gmail.com>
2022-09-29 14:29:02 +03:00
Delyan Angelov
6fcab013eb os.notify: fix sizeof(C.epoll_event) == 12 with tcc (was 16, while with gcc/clang it is 12) 2022-09-29 13:27:07 +03:00
Delyan Angelov
3b420a8d7f net.urllib: add a URL.debug() method, returning the values of all the URL's fields 2022-09-29 10:38:11 +03:00
shove
e2cf403ca1 fmt: fix error when comments inside if and condition. (fix #15914) (#15915) 2022-09-29 09:14:11 +03:00
Swastik Baranwal
1ff1f23d9a parser: disallow using attributes on embedded structs (#15901) 2022-09-28 17:15:33 +03:00
shove
1ac3f3d8dc parser: fix pos error when define reference array type (fix: #15907) (#15909) 2022-09-28 17:13:29 +03:00
TSURUTA Takumi
e72d259903 change Values struct to public (#15902) 2022-09-28 16:21:33 +03:00
yuyi
be6741195d parser: fix formating fn with variadic argument (#15900) 2022-09-28 10:55:36 +03:00
Tim Marston
66249b8c45 gg: radius_to_segments() should use Context.scale (#15906) 2022-09-28 10:40:40 +03:00
spaceface
b85a535bcd cgen: support closures on riscv (#15898) 2022-09-28 10:34:26 +03:00
yuyi
bdf4c679da cgen: minor cleanup in method_call() (#15894) 2022-09-27 20:05:04 +03:00
yuyi
57e4ba4cd0 checker: fix generics interface with generic sumtype (fix #15883) (#15892) 2022-09-27 16:33:34 +03:00
lemon
f1216090f7 native: support enum (#15895) 2022-09-27 13:31:54 +03:00
Joe Conigliaro
51a92d170f encoding.base32: vfmt code 2022-09-27 16:29:44 +10:00
Joe Conigliaro
5415c4f75e encoding.base32: initial implementation 2022-09-27 16:25:50 +10:00
yuyi
385acb448a cgen: fix dumping c structs (fix #15878) (#15885) 2022-09-26 10:53:21 +03:00
yuyi
959eeaf1f3 parser: check undefined variable in if guard (#15882) 2022-09-26 10:17:39 +03:00
kahsa
8623186d31 doc: add links to vlib doc - array and map (#15881) 2022-09-26 10:06:54 +03:00
Dominik Pytlewski
721328ef58 os: fix os.read_file and os.read_bytes for 0 sized /proc/ files on Linux (fix #15852) (#15853) 2022-09-25 22:54:46 +03:00
Nicolas VENTER
50820105a1 docs: call_v_from_c example (#15844) 2022-09-25 22:52:40 +03:00
Subhomoy Haldar
7f23abbf8c docs: document the [noinit] attribute with an example (#15876) 2022-09-25 19:36:01 +03:00
Spydr
3674baab23 native: support escape sequences in string literals (#15877) 2022-09-25 17:47:49 +03:00
Tim Marston
089e89f865 gg: improve arc/slice drawing (#15856) 2022-09-25 15:22:10 +03:00
shove
58f7342465 cgen: fix array appending when array is used as fn parameter (fix: #15855) (#15860) 2022-09-25 13:05:54 +03:00
Delyan Angelov
6637db2d6d tools: fix sporadic CI failures on the doom-regressions job due to v gret 2022-09-25 11:27:13 +03:00
yuyi
50fb5de926 checker: fix dumping match expr (#15869) 2022-09-25 11:21:14 +03:00
Delyan Angelov
5cc9d7b347 checker: remove too vague notice about signed expressions while returning unsigned number types 2022-09-25 11:03:23 +03:00
yuyi
c3548c9413 tests: omit testsuite_begin/end() optional (#15871) 2022-09-25 10:29:25 +03:00
Spydr
947a1f2c65 native: add printing support for boolean and string variables (#15868) 2022-09-25 10:28:26 +03:00
Delyan Angelov
f338dec5c6 ci: fix compilation on FreeBSD (C.feof is a macro there, that expands to direct field access) 2022-09-24 10:17:32 +00:00
yuyi
d624ad50a7 os: fix file.read() (#15861) 2022-09-24 08:58:55 +03:00
Alexander Medvednikov
91c6e1a65b changelog: 0.3.2 2022-09-24 02:13:10 +03:00
shove
13d7f7db8f parser: fix line number error of comptime atExpr in the last token of the line (fix: #15672) (#15851) 2022-09-24 00:06:07 +03:00
yuyi
c811b5343a cgen: minor cleanup in return_stmt() (#15854) 2022-09-23 23:46:15 +03:00
yuyi
41fd02496a cgen: fix const expr using optional or result (#15850) 2022-09-23 22:36:56 +03:00
Delyan Angelov
1f26e3fb1b datatypes: add a forward iterator for LinkedList<T>, add forward and backward iterators for DoublyLinkedList<T>. Add tests for both. 2022-09-23 22:29:13 +03:00
Delyan Angelov
a6576bec1d json: fix encoding of structs with pointers; add test 2022-09-23 14:07:53 +03:00
ChAoS_UnItY
ea8b30fd91 encoding.utf8: add is_space (#15847) 2022-09-23 10:34:45 +03:00
shove
6ec931c781 sync: fix C.pthread_mutex_t struct typedef is missing in darwin (fix: #15491) (#15845) 2022-09-23 09:48:05 +03:00
spaceface
5c716afb39 net.ssl: switch to mbedtls over openssl (#15841) 2022-09-22 16:50:34 +03:00
yuyi
44c3fcecd9 cgen: fix reference embed method call (#15842) 2022-09-22 13:53:11 +03:00
Carl Xiong
78f8b9eb28 v.scanner: fix an unicode string escape handling bug (#15834) 2022-09-22 13:44:55 +03:00
Alfie Ranstead
27305d1a5f net.websocket: swap unsafe use of nil for a safe default value (#15836) 2022-09-22 08:00:03 +03:00
yuyi
41dbd12bc4 tests: make error handling the same as the main function (#15825) 2022-09-21 19:45:43 +03:00
flopetautschnig
391ac12fe2 datatypes: adding ringbuffer (#15818) 2022-09-21 19:42:59 +03:00
Delyan Angelov
09411128af json.cjson: add a test case for more complex json object construction 2022-09-21 17:22:42 +03:00
Delyan Angelov
21c5cadc59 tools: fix v install https://some/url_with_underscores (make --git the default for URLs) 2022-09-21 15:44:49 +03:00
shove
0871eca177 tests: add test for using reference of map type as struct field (PR #15828) (#15830) 2022-09-21 12:20:19 +03:00
spaceface
201598e68a builtin: fix gc.o compilation on macos (#15832) 2022-09-21 12:19:02 +03:00
Delyan Angelov
d848311fe2 tests: add missing script_with_no_extension, add exception for /tmp.* files in .gitignore 2022-09-20 16:17:21 +03:00
Annie
8f7958273b compiler: add -raw-vsh-tmp-prefix tmp flag, to allow for executing scripts without .vsh extension (#15829) 2022-09-20 15:52:18 +03:00
spaceface
453cc41c32 builder: remove outdated tcc error (#15833)
This was introduced when we enabled the GC by default,as a suggestion
for resolving C errors caused by the user having an outdated TCC clone.
However, now that several months have passed, it is very unlikely that
people still have out-of-date copies of TCC, and instead it is more likely
that this error message is hiding the true cause of some C errors unrelated
to TCC or the GC.
2022-09-20 15:12:39 +03:00
shove
bbf1ba458e cgen: fix using reference of sumtype or map as struct field (fix: #15827) (#15828) 2022-09-20 13:22:08 +03:00
Wertzui123
a9d63d729e sokol.sapp,gg: add a tool_type field to gg.TouchPoint (differenciate different types of touch input) (#15822) 2022-09-20 13:15:38 +03:00
Delyan Angelov
993802f6a6 markused: fix compilation of gg programs with -skip-unused, add test to prevent regressions (#15821) 2022-09-20 08:03:03 +03:00
Swastik Baranwal
42059ee099 checker: disallow array append as expression in .map and `.filter methods (#15823) 2022-09-20 07:30:30 +03:00
Delyan Angelov
69c9d47a40 pref,os,sokol,cgen: ease compilation of 2048 with -os wasm32_emscripten (#15820) 2022-09-20 00:17:13 +03:00
yuyi
e6e3751980 checker: fix generics with pointer index (fix #15810) (#15815) 2022-09-19 22:02:49 +03:00
yuyi
a0d647d1e3 checker: clean up checking optional and result in checker.v (#15817) 2022-09-19 14:52:27 +03:00
shove
84bc170720 checker: optimize the position of the propagation error, where a fn needs to return an optional or result(fix #15780) (#15813) 2022-09-19 14:49:23 +03:00
Ikko Ashimine
0ff53d18c1 v.gen.js: fix typo in js.v (#15812) 2022-09-19 10:22:24 +03:00
Delyan Angelov
5c21b83044 cgen: skip generating typedef HANDLE __v_thread on windows, when -no-builtin is given 2022-09-19 09:14:25 +03:00
Delyan Angelov
d7758b2995 checker: fix slow compilation of vtl/nn/examples/mnist.v (reduce RAM usage) 2022-09-18 21:43:44 +03:00
Delyan Angelov
04f818fefc ci: cleanup paths-ignore: usage in ci_sanitized.yml and native_backend_tests.yml 2022-09-18 18:47:41 +03:00
shove
202585e175 checker, parser, fmt: fix visibility of anon struct in different modules.(fix #15763) (#15787) 2022-09-18 18:08:33 +03:00
yuyi
0ff74dae63 vrepl: simplify and cleanup vrepl (#15807) 2022-09-18 18:07:16 +03:00
yuyi
57d583d821 cgen: fix array insert in fn as mut receiver (#15806) 2022-09-18 14:55:28 +03:00
frittex
24ea6dfe14 docs: add note that clang is required (#15802) 2022-09-18 14:22:01 +03:00
yuyi
8d2b0d4afd parser: fix error for match expr with 'fn' (#15805) 2022-09-18 14:17:13 +03:00
yuyi
c78344ef04 vrepl: fix output errors (fix #15801) (#15804) 2022-09-18 14:09:31 +03:00
Delyan Angelov
d67aa8d76c checker: improve the wording of the mismatched range types error 2022-09-17 21:05:30 +03:00
shove
bd3c9e888d checker: fix missing checker error for fn abc() u64 { return -1 } (fix #15789) (#15795) 2022-09-17 20:59:52 +03:00
yuyi
085a09ebdb vrepl: fix output error of print and fn call (#15796) 2022-09-17 15:58:53 +03:00
Delyan Angelov
afe7166346 v.builder: add -Wno-write-strings for tcc on -cstrict 2022-09-17 15:38:06 +03:00
yuyi
de636dbb2b checker: check result type method call (#15794) 2022-09-17 11:45:13 +03:00
yuyi
26443cf9fa vrepl: fix array method call errors (fix #15769) (#15786) 2022-09-17 10:12:01 +03:00
Delyan Angelov
a3b60e6b55 checker: improve mismatched range types error messages 2022-09-17 09:15:55 +03:00
Delyan Angelov
fda39bfb82 docs: enhance the .vsh section, as well as the description of the V's script mode (no fn main(){}) (#15788) 2022-09-17 00:21:31 +03:00
shove
289f8f2f24 checker: fix nested struct ref field init check for embedded structs (fix #15768) (#15785) 2022-09-16 23:39:15 +03:00
Delyan Angelov
0992914bd6 ci: remove macos-10.15 runner (affected by a brownout, and scheduled to be removed in 12/1/2022)
See: https://github.com/actions/runner-images/issues/5583
The brownouts for this runner image, will get increasingly more frequent.
2022-09-16 21:01:52 +03:00
Carl Xiong
0b6924ebfb cgen: fix hardcoded app param name in code generated for vweb.html (#15766) 2022-09-16 17:27:58 +03:00
lemon
7f30519544 native: support method definition and call (#15736) 2022-09-16 16:31:05 +03:00
yuyi
0e49ce427e cgen: fix passing sumtype parameter in sumtype matching results (fix #15078) (#15767) 2022-09-16 10:16:40 +03:00
Delyan Angelov
f922ed0941 tests: unify all temporary files/folders under $VTMP/v, that can be cleaned by v wipe-cache (#15774) 2022-09-16 04:56:19 +03:00
Delyan Angelov
7e69619add builtin, compiler: replace isnil(x) calls with x == unsafe { nil } (a little faster without -prod) (#15759) 2022-09-15 14:59:37 +03:00
Swastik Baranwal
f09197b972 cgen: fix printing and dumping of struct having referenced interface as field (#15765) 2022-09-15 12:43:23 +03:00
shove
566a61b136 checker: fix check omission in cast string to char. (fix #15760) (#15764) 2022-09-15 09:33:38 +03:00
shove
8b962f8446 checker: fix nested struct reference type field initialized check. (fix: #15741) (#15752) 2022-09-15 07:59:31 +03:00
yuyi
5719344653 checker: fix struct init with update of mutable receiver (#15758) 2022-09-14 19:46:05 +03:00
yuyi
ea4152ee14 checker: add a test for fn call arg of fn pointer mismatch (#15757) 2022-09-14 17:46:07 +03:00
yuyi
fd1b3fc861 cgen: fix error of 'in array of sumtype' (#15756) 2022-09-14 17:43:16 +03:00
Larpon
0b2841d4ea docs: add nested map example. Closes #15751 (#15753) 2022-09-14 10:32:09 +03:00
yuyi
ac64318890 checker: check casting array to number (#15750) 2022-09-13 20:41:20 +03:00
yuyi
840370f345 cgen: minor optimization in if_expr() (#15748) 2022-09-13 14:56:09 +03:00
Swastik Baranwal
a3d6a9349d cgen: make go func with array type work (#15747) 2022-09-13 14:53:43 +03:00
shove
f51384c402 cgen: modify the temporary variable name of the previous pr 15744 (#15745) 2022-09-13 12:11:03 +03:00
shove
7cff7fb828 cgen: fix f as Fun, where f is type Expr = Fun | int, and struct Fun { f fn (int) int }. (fix #15730) (#15744) 2022-09-13 10:19:58 +03:00
yuyi
adc3b25f52 checker, cgen: fix nested if expr with optional or result (fix #15735) (#15743) 2022-09-13 10:09:12 +03:00
yuyi
e51f0be6db checker: check taking the address of map field outside unsafe block (#15737) 2022-09-13 10:04:21 +03:00
Sanath Kumar U
ac6167565e docs:Update docs.md to include instructions on upgrading V (#15733)
* Updated docs.md to include instructions on upgrading V

Updated docs.md to include instructions on upgrading V to latest version.

* changes to fix the error message "./doc/docs.md:27:116: error: must be less than 100 characters"
2022-09-12 18:26:10 +03:00
yuyi
17b54cde97 checker: fix match with complex sumtype exprs that adding print (#15728) 2022-09-12 13:55:34 +03:00
yuyi
b4494f921a ast: fix dumping sumtype of fntype (#15734) 2022-09-12 13:45:29 +03:00
shove
550b27b014 checker: fix recursive define check is missing when defining sumtype. (fix #15684) (#15718) 2022-09-11 15:17:38 +03:00
shove
be0dc0e537 checker: fix check omission in cast string to ptr. (fix #14921) (#15721) 2022-09-11 13:54:56 +03:00
Delyan Angelov
3e599a1436 ci: ignore vlib/v/tests/inout/vscript_using_generics_in_os.vsh in v test-cleancode on windows for now 2022-09-11 11:18:01 +03:00
shove
8b5f3aa970 checker: fix inner functions are called before definition. (fix #15673) (#15719) 2022-09-11 11:10:47 +03:00
lemon
aa3651fa58 native: add initial implementation of simple structs (#15722) 2022-09-11 11:05:12 +03:00
Delyan Angelov
e03ca2026b checker: fix generic fns usage in implicitly imported os in .vsh script mode 2022-09-11 10:47:47 +03:00
yuyi
7eb36789ac checker, cgen: fix nested match expr with optional or result type (#15717) 2022-09-10 11:44:22 +03:00
shove
bce1039c9c cgen: fix missing type name when anonymous struct is used as parameter. fix #15698 (#15699) 2022-09-10 09:35:42 +03:00
Spydr
b429aad63b native: add struct representing elf headers (#15716) 2022-09-10 09:29:46 +03:00
Louis Schmieder
f249feb9da orm: support parenthesized expressions as in select from User where (name == 'Sam' && is_customer == true) || id == 1 (#15693) 2022-09-09 21:08:48 +03:00
yuyi
61a4b469a3 cgen: fix nested match expr with optional or result (#15713) 2022-09-09 18:23:56 +03:00
Delyan Angelov
e7725bb340 ci: enable again failing on Doom visual mismatches. Increase Xvfb screen size in c2v.yml (better see Doom screenshots when there is a difference) 2022-09-09 17:51:03 +03:00
shove
ca36284612 fmt: fix anonymous struct in parameter with invalid type name. fix #15696 (#15711) 2022-09-09 14:44:49 +03:00
Swastik Baranwal
6db5781d53 checker: add checks for .map(opt_fn_name) and .filter(opt_fn_name) (#15687) 2022-09-09 12:24:57 +03:00
yuyi
0f3a395ca2 checker, cgen: fix if expr with result (#15709) 2022-09-09 11:29:21 +03:00
yuyi
71f5f7f3a7 cgen: fix if expr with fn call result (#15702) 2022-09-08 22:39:49 +03:00
yuyi
ec2ca38adb checker, cgen: fix match expr with result (#15706) 2022-09-08 21:24:16 +03:00
Ken
1738641567 cgen, checker, ast: add syntax support for reference x in for x in &somearrary { and for x in &somemap { loops (#15678) 2022-09-08 13:36:40 +03:00
flopetautschnig
9641ced901 vweb.csrf: add a README.md, correct doc comments for public functions (#15697) 2022-09-08 13:20:29 +03:00
yuyi
5c900e23de cgen: fix const aliases of bytes fixed array (#15701) 2022-09-08 13:19:02 +03:00
Delyan Angelov
fc8e3d0971 builtin,strconv: speedup str.int() conversions (without -prod) 2022-09-08 11:28:19 +03:00
yuyi
a462610376 ast: minor optimization in sumtype_check_function_variant() (#15694) 2022-09-08 09:20:30 +03:00
shove
a75a12ec1e checker: fix const variable type error when global variable with the same name exists (fix #15686) (#15689) 2022-09-07 19:06:45 +03:00
Emin Arıcan
7672725204 net: fix typo (#15688) 2022-09-07 16:35:28 +03:00
yuyi
8627af18dd table: check sumtype of fntype assign error (#15685) 2022-09-07 16:05:38 +03:00
yuyi
2693935066 checker: check non generic struct used like a generic one (#15690) 2022-09-07 14:53:43 +03:00
Delyan Angelov
c5ed179e76 arrays: remove deprecation from arrays.concat/2; it is a useful abstraction for operating on immutable arrays 2022-09-07 13:25:40 +03:00
Hitalo Souza
21b2a9841a examples: js_dom_draw_bechmark_chart (#15518) 2022-09-07 01:55:32 +03:00
yuyi
ca99a1d355 cgen: fix sumtype with fntype using fn directly (fix #15674) (#15679) 2022-09-06 20:33:39 +03:00
flopetautschnig
1c63ce479c vweb: adding a vweb.csrf protection module (#15586) 2022-09-06 13:18:39 +03:00
Hitalo Souza
95a328be98 orm: improve the README and the tests. Add an error message for foreign key tags (#15670) 2022-09-06 13:12:37 +03:00
yuyi
e3d3863fbe cgen: refactor need_tmp_var_in_expr/match() (fix #15675) (#15676) 2022-09-06 13:09:28 +03:00
shove
862d91ed0a checker: check for name conflicts between const and __global variables (fix #15668) (#15669) 2022-09-05 18:58:30 +03:00
yuyi
6fd22531a9 cgen: fix if expr with index expr (#15666) 2022-09-05 18:55:53 +03:00
yuyi
d649f5aff4 checker, cgen: fix go call fn using map value (#15665) 2022-09-05 17:16:28 +03:00
Seven Du
90c2c5b8a4 token: add @FILE_LEN (#15661) 2022-09-05 17:00:35 +03:00
yuyi
d0d5f1d4e0 cgen: fix fn variable name using reserved c word (fix #15647) (#15648) 2022-09-04 17:50:41 +03:00
Swastik Baranwal
436b19c408 checker: add error for mismatched types and format character for string interpolation (#15639) 2022-09-04 14:15:26 +03:00
yuyi
78998a09e4 cgen: fix go call anon fn with closure (#15656) 2022-09-04 14:03:24 +03:00
Delyan Angelov
57802aaffc ci: install xsel and xclip on the jobs where imgur.sh is used 2022-09-04 13:46:27 +03:00
Larpon
0d0c2b278d vgret: add region support (#15651) 2022-09-04 13:39:10 +03:00
jrfondren
45e21bc311 os: remove private unix_environ() helper function, it is not needed anymore (#15654) 2022-09-04 13:22:38 +03:00
yuyi
0c84ad847e cgen: fix match expr with optional (#15658) 2022-09-04 13:21:16 +03:00
Delyan Angelov
cee8b38221 ci: disable job failure on doom picture regressions for now 2022-09-04 13:04:02 +03:00
Delyan Angelov
dd78620b31 cgen: fix [packed] struct support for tcc 2022-09-04 07:14:01 +03:00
yuyi
5e1a2f6f50 checker: check if guard with multiple return variable (#15646) 2022-09-03 10:56:46 +03:00
yuyi
a5aad6f791 cgen: fix alias of map delete (#15644) 2022-09-03 10:41:53 +03:00
yuyi
1ef95fdec6 cgen: fix assert value is '*unknown value*' (#15645) 2022-09-03 10:38:27 +03:00
Davide Beatrici
4bd49a0149 ci: run more tests on the FreeBSD Cirrus runner (#15602) 2022-09-01 21:56:43 +03:00
yuyi
42e582804e checker: check fn variadic passing arg error (fix #15629) (#15632) 2022-09-01 21:24:24 +03:00
yuyi
bfdd6f1cf8 csv: minor cleanup in writer.v (#15633) 2022-09-01 21:23:18 +03:00
Delyan Angelov
728b198384 os: extract dir_expansions_test.v from os_test.v 2022-09-01 13:07:29 +03:00
Delyan Angelov
0cc0e87051 time: use linux_utc() and linux_now() on freebsd too (more precise, and fixes time_test.v) 2022-09-01 09:54:20 +00:00
Davide Beatrici
23e8fca4f9 native: fix order and add missing path in find_o_path() (#15622)
This fixes the linker failing when:

- 32 bit libraries exist in "/usr/lib".
- 64 bit libraries are in "/usr/lib64" and not "/usr/lib/x86_64-linux-gnu".
2022-09-01 10:21:35 +03:00
Wertzui123
95760ae82a CHANGELOG.md: fix typo (paralell -> parallel) (#15621) 2022-09-01 09:26:05 +03:00
yuyi
5e8f9b11c9 checker: check casting voidptr to generic struct (fix #15618) (#15626) 2022-09-01 09:22:37 +03:00
Alexander Medvednikov
f2f6ea5969 V 0.3.1 2022-08-31 19:24:57 +03:00
Louis Schmieder
fef26a0b19 fmt: fix striping modules prefix in orm (#15005) 2022-08-31 19:23:36 +03:00
yuyi
806c39d46e parser: fix error for match sumtype with fntype (#15620) 2022-08-31 18:44:12 +03:00
Louis Schmieder
6110373519 orm: init or implementation (#14989) 2022-08-31 14:43:20 +03:00
Haren S
bc06866b20 make: add clock_gettime on macOS < 10.12 (fix #6605) (#15611) 2022-08-31 11:03:25 +03:00
yuyi
4d6b8cbfd8 cgen: fix casting sumtype as fntype (#15612) 2022-08-31 10:45:47 +03:00
yuyi
64f403e997 cgen: fix dumping shared variable (#15615) 2022-08-31 10:42:28 +03:00
yuyi
56135dbdbc cgen: fix printing reference enum (#15606) 2022-08-30 14:24:48 +03:00
Alexander Medvednikov
ba1045e5fd parser: deprecate inline sum types 2022-08-30 13:18:22 +03:00
yuyi
b154af032b parser: fix sumtype with multi fntype (fix #15557) (#15583) 2022-08-30 12:48:25 +03:00
yuyi
5d4492ac6f checker: check cast to reference struct (fix #15590) (#15601) 2022-08-30 11:42:21 +03:00
crthpl
a9b54e9b98 cgen: add __addr (bootstraps #14818) (#15585) 2022-08-30 10:28:47 +03:00
lemon
2221dd7058 native: support fncall with 7↑ arguments (#15599) 2022-08-30 10:24:37 +03:00
yuyi
0876cf86ed cgen: fix struct init with update expr (fix #15595) (#15603) 2022-08-30 09:22:14 +03:00
yuyi
e355ae7b3c checker: check generics struct field type error (#15593) 2022-08-29 16:55:26 +03:00
Delyan Angelov
9703410391 vfmt: fix formatting of submodules with common prefixes (fix #15582) 2022-08-29 15:30:58 +03:00
Larpon
1915bf81d0 ci: use ubuntu-latest for toml tests (#15591) 2022-08-29 12:43:50 +03:00
shove
f285ebd91c smtp: add base64 encoding to the body of the emails and use utf8, to prevent format confusion (#15589) 2022-08-29 09:19:46 +03:00
yuyi
72056f36d8 cgen: fix cross assign of fixed array (#15587) 2022-08-29 08:50:19 +03:00
Larpon
f23ebb6815 docs: "in over a" -> "in a" (#15576) 2022-08-28 20:51:45 +03:00
ChAoS_UnItY
ad76c9c719 checker: fix illegal result propagate on non-result type (fix #15574) (#15578) 2022-08-28 13:31:45 +03:00
ChAoS_UnItY
258ff73efd encoding.csv: re-encapsulate fields in Writer/Reader (fix #15558) (#15570) 2022-08-28 11:13:43 +03:00
Hitalo de Jesus do Rosário Souza
797bdd5e98 vweb: document the .query field (#15572) 2022-08-28 09:55:18 +03:00
yuyi
06e153d429 ast, cgen: implement sumtype with fntype partly (related #15557) (#15567) 2022-08-28 09:12:08 +03:00
Delyan Angelov
d75c62b806 checker: allow + operator overrides for type aliases 2022-08-27 12:54:16 +03:00
yuyi
2a03d22a37 ast: clean up table.find_or_register_fn_type() (#15560) 2022-08-27 09:32:03 +03:00
ChAoS_UnItY
0b843b801f checker: fix returning expression with void type (fix #15543) (#15554) 2022-08-27 09:00:14 +03:00
ChAoS_UnItY
70de4e1009 checker: fix no error on plus-assigning array (fix #15544) (#15552) 2022-08-26 23:11:23 +03:00
yuyi
f45042fa09 checker: improve error message of fn args mismatch (#15550) 2022-08-26 22:38:53 +03:00
Delyan Angelov
329670431b v.pref: skip vlib/builtin/prealloc.c.v, when -prealloc is not passed (#15553) 2022-08-26 22:08:42 +03:00
Delyan Angelov
a1e87664f4 ci: minimise work on commits/PRs, that affect only .yml files 2022-08-26 21:07:33 +03:00
Delyan Angelov
511cc2b267 ci: prevent native-backend jobs from separate PRs to cancel each other 2022-08-26 20:58:19 +03:00
lemon
e5c53cf412 native: match expr/stmt (#15537) 2022-08-26 15:18:02 +03:00
yuyi
02a47f42f3 ast, parser, cgen: fix closure with nested closure variable (#15542) 2022-08-26 13:37:10 +03:00
Subhomoy Haldar
3af12271fb log: add target_from_label and unit tests (#15538) 2022-08-26 07:09:48 +03:00
ChAoS_UnItY
b0e7ddfd97 checker: fix non-bool check on use of result bool (fix #15539) (#15540) 2022-08-26 07:08:57 +03:00
StunxFS
b83dd86d65 checker: check error for simple assignment with dumping of multireturn value (#15512) 2022-08-26 07:08:05 +03:00
lemon
939e9245db native: support integer infix arithmetics (#15536) 2022-08-26 07:07:15 +03:00
wahur666
dbf28c5bfb cmd/tools/where: check if parent already included vlib_dir (#15527) 2022-08-26 07:04:44 +03:00
yuyi
fc9d2d5d5e cgen: cleanup generic_fn_name() (#15531) 2022-08-26 07:04:10 +03:00
Swastik Baranwal
44137e07b0 datatypes: use generic op overloading for difference and equal (#15530) 2022-08-26 07:03:23 +03:00
shove
c10c8ff9e4 parser: fix anon struct name conflict (#15517) 2022-08-26 07:01:50 +03:00
tr00
3eb6ad7b8c os: fix type in error message (#15533) 2022-08-26 06:59:52 +03:00
yuyi
40c0a8cbaf parser, checker, cgen: implement generics anon fn (#15529) 2022-08-25 14:12:56 +03:00
shove
723b3d74ee datatypes: add array() method for LinkedList, DoublyLinkedList, Queue, and Stack (#15524) (#15525) 2022-08-25 14:12:39 +03:00
yuyi
c662431cfd checker: check unsafe array assign (fix #9651) (#15515) 2022-08-25 08:52:13 +03:00
yuyi
86496aa191 cgen: fix array init with it (#15523) 2022-08-25 08:00:11 +03:00
Delyan Angelov
3ad22eb0dd checker: show a more detailed error for invalid declarations of generic methods on generic structs. 2022-08-24 13:43:27 +03:00
Delyan Angelov
4718b8b45a all: unify the displaying of compiler errors, using a common util.show_compiler_message/2 function. 2022-08-24 13:38:47 +03:00
StunxFS
0d8b6ee7f2 checker: don't show manual memory warning twice (#15510) 2022-08-24 09:08:35 +03:00
shove
6ff753745f smtp: send mail to multiple recipients. #15508 (#15509) 2022-08-23 20:50:41 +03:00
Subhomoy Haldar
3b42f18dee os: add input_password(prompt) and unit tests (#15507) 2022-08-23 18:17:38 +03:00
Swastik Baranwal
d08edf8cba vdoc: highlight generic struct everywhere (#15506) 2022-08-23 15:21:26 +03:00
Delyan Angelov
3c23eebe51 ci: fix -fsanitize=address for c_array_test.c 2022-08-23 12:16:55 +03:00
yuyi
42c0bae9ce checker: check unknown array of fn type in struct field (#15502) 2022-08-23 11:15:25 +03:00
Larpon
9dd8228f91 arrays: move carray_to_varray from builtin, make it generic (#15503) 2022-08-23 11:12:50 +03:00
Alexander Medvednikov
2dde7ff5ba strconv: deprecate v_sprintf in favor of string interpolation 2022-08-23 09:53:05 +03:00
yuyi
a758b6686c json: minor cleanup in json_test.v (#15501) 2022-08-23 07:59:50 +03:00
yuyi
196b5f8e3a checker: fix match expr with non last if expr (#15500) 2022-08-23 07:58:33 +03:00
Delyan Angelov
98c6dad887 make.bat: add a small delay between del v.exe and move v2.exe v.exe, to make CI runs more robust 2022-08-22 22:08:47 +03:00
Larpon
d40d761e38 toml: support [toml: '...'] attributes (#15497) 2022-08-22 20:39:55 +03:00
Larpon
dda475bcc8 builtin: add carray_to_varray, closes #15493 (#15499) 2022-08-22 20:15:54 +03:00
Delyan Angelov
a689641c1b os: rewrite os.walk and os.walk_with_context to use iteration, instead of recursion 2022-08-22 17:27:14 +03:00
Delyan Angelov
21917f5b00 os: small cleanup of needless r'\' usage 2022-08-22 16:32:42 +03:00
Delyan Angelov
e156e6a44a os: remove commented code in os_windows.c.v 2022-08-22 14:54:38 +03:00
yuyi
d7501cc9a1 cgen: fix if sumtype var is none (#15496) 2022-08-22 13:32:27 +03:00
yuyi
18b6311b2f cgen: fix match sumtyp var with none (#15495) 2022-08-22 13:31:35 +03:00
irishgreencitrus
8db945ec52 vpm: force v install to clone git submodules too (#15487) 2022-08-22 11:23:32 +03:00
yuyi
47e75c68a9 cgen: fix json.encode of a struct containing a field of an alias type of another struct (#15490) 2022-08-22 11:04:58 +03:00
Swastik Baranwal
f727433929 scanner: add check for invalid unicode (#15485) 2022-08-22 10:56:51 +03:00
yuyi
6d501b073a datatypes: make Set's methods public (#15489) 2022-08-22 10:16:59 +03:00
Delyan Angelov
661d70a976 ci: run VLS tests with gcc on the main V repo too 2022-08-22 10:10:59 +03:00
Delyan Angelov
24e0a6cff2 checker: fix vls test compilation 2022-08-22 08:42:58 +03:00
yuyi
0d9ac1f59c checker: improve error message for test function definition (#15483) 2022-08-21 16:19:39 +03:00
yuyi
f194d3ca2e checker: fix generic method with nested generic method (#15480) 2022-08-21 14:12:31 +03:00
Delyan Angelov
3656d445ab Revert "Revert "tools/fast: do not build V with -usecache""
This reverts commit ad322f4eb0.
2022-08-21 10:40:27 +03:00
Delyan Angelov
ad322f4eb0 Revert "tools/fast: do not build V with -usecache"
This reverts commit f97a4f1904.
2022-08-21 08:56:05 +03:00
Delyan Angelov
0b41ff0c6a v.vcache, v.builder: use the module name inside the usecache paths (for more readable cache entries at a glance) (#15476) 2022-08-21 08:55:21 +03:00
Alexander Medvednikov
a069577e9c builder: remove msvc code from non windows systems 2022-08-21 05:21:31 +03:00
Alexander Medvednikov
12265a15ed pref: temp hack to make -os cross work when building V 2022-08-21 05:12:58 +03:00
Alexander Medvednikov
f97a4f1904 tools/fast: do not build V with -usecache 2022-08-21 04:40:32 +03:00
Alexander Medvednikov
eb6627fe41 cgen: remove unneeded comments 2022-08-21 01:39:54 +03:00
Delyan Angelov
9932ed9b7e doc: add a Parameter evaluation order section (#15473) 2022-08-21 01:08:38 +03:00
Delyan Angelov
c3568823ee tests: make vlib/time/private_test.v more robust/tolerant to small fluctuations 2022-08-20 13:56:10 +03:00
Delyan Angelov
499ab9bedb tests: make tcp_self_dial_from_many_clients_test.v more robust (use shared ctx) 2022-08-20 13:32:59 +03:00
Hitalo de Jesus do Rosário Souza
eafbf335cf docs: improve vlib/vweb/README.md (#15146) 2022-08-20 12:06:24 +03:00
Swastik Baranwal
a1de8f5f98 vdoc: highlight variadic function parameters (#15474) 2022-08-20 12:02:50 +03:00
yuyi
0645fe3322 parser: check generic struct init using multi return type (#15472) 2022-08-20 11:56:44 +03:00
Delyan Angelov
5cba5920d5 os: make find_abs_path_of_executable_test.v more robust (fix #15459) 2022-08-20 10:06:58 +03:00
yuyi
6062708c60 checker: fix comptime if generic value shift (#15471) 2022-08-20 08:15:52 +03:00
Alexander Medvednikov
46f32fc10c checker: require unsafe for free() 2022-08-20 08:03:07 +03:00
yuyi
fa447443ca cgen: fix push on closed channel (#15468) 2022-08-19 19:27:42 +03:00
Alwin Arrasyid
6ed69289a8 tutorials: remove unnecessary json.encode (#15464) 2022-08-19 19:27:26 +03:00
yuyi
f10ff0353e checker, fmt: check infix_expr with 'and' op (#15466) 2022-08-19 09:50:46 +03:00
Delyan Angelov
31067d4a6c ci: ignore changed .md files in native_backend_tests.yml 2022-08-19 09:49:17 +03:00
yuyi
1dc62a5a66 ast: fix string interpolation fmt with result call (#15467) 2022-08-19 09:44:59 +03:00
yuyi
ea163197c7 cgen: fix shared optional (#15462) 2022-08-18 20:18:03 +03:00
yuyi
6d399c5116 checker: fix struct init with update expr (fix #9472) (#15460) 2022-08-18 19:39:41 +03:00
Swastik Baranwal
22a79cfa1e v doc: add highlighting for new types and fix highlighting for edge cases (#15455) 2022-08-18 18:06:55 +03:00
irishgreencitrus
cd31108260 cgen: implement '#preinclude' (#15456) 2022-08-18 15:59:08 +03:00
yuyi
7227c1d508 scanner: fix false &&!ok1 (fix #7524) (#15458) 2022-08-18 11:55:38 +03:00
Larpon
af8bd10761 v.pref: support v -trace-calls run file.v (#15450) 2022-08-18 11:45:37 +03:00
yuyi
d3307fd2e3 cgen: minor cleanup in fn_var_signature() (#15454) 2022-08-17 18:42:46 +03:00
Delyan Angelov
7ed3389fa8 ci: fix -cstrict checks after 7585e86 2022-08-17 18:40:15 +03:00
Delyan Angelov
18e737aee2 builtin,tests: fix int_test.v on macos, m1 2022-08-17 17:18:10 +03:00
Delyan Angelov
7585e86868 os: reduce heap allocations done by os.real_path, os.executable, os.getwd 2022-08-17 17:06:38 +03:00
Delyan Angelov
0e62344043 tests: make private_test.v more tolerant to small delays 2022-08-17 16:25:46 +03:00
yuyi
e1ebd90190 cgen: fix array of fixed array map/filter/any/all(it[0]) (fix #15422) (#15445) 2022-08-17 16:16:08 +03:00
yuyi
9887dd1fbf cgen: fix go call fn with anon fn argument (fix #10351, fix #10270) (#15446) 2022-08-17 16:12:52 +03:00
ChAoS_UnItY
70f466460f cgen: fix struct field name generation in auto free (#15440) 2022-08-17 09:11:58 +03:00
yuyi
374186f1f7 checker: fix fn call with mut array of aliases arguments (#15443) 2022-08-17 08:49:53 +03:00
John
d41b2be3a7 crypt: implement crypto.rand.read/1 for OpenBSD and FreeBSD (#15437) 2022-08-17 07:41:27 +03:00
Alexander Medvednikov
8736f26a1c tutorials: simplify new_article() a bit 2022-08-16 22:20:03 +03:00
Vladimir Myshkovski
9b9115471f datatypes: Set implementation (#14853) 2022-08-16 20:23:48 +03:00
yuyi
b08f500c60 cgen: fix fn_var_signature() when param type is function (#15436) 2022-08-16 20:21:58 +03:00
yuyi
dc37386bcc cgen: minor optimization in return_stmt() (#15434) 2022-08-16 20:21:02 +03:00
Markus F.X.J. Oberhumer
77fd1419a7 cgen: avoid another sizeof warning in generated code (#15435) 2022-08-16 20:20:13 +03:00
Delyan Angelov
18cccb6caf builtin: show non zero codes on bubbled error_with_code(msg,code) errors 2022-08-16 18:59:38 +03:00
yuyi
66a3cdec6a cgen: add fn_var_signature(info ast.FnType, var_name string) string (#15433) 2022-08-16 12:57:33 +03:00
Swastik Baranwal
3bc01d696d cgen: fix []u8 string representation (#15432) 2022-08-15 23:48:38 +03:00
Nikolai
3aad5e2a8d cgen, checker: fix multi line return optional (#15428) 2022-08-15 23:43:56 +03:00
yuyi
8be85e7590 cgen: fix shared map delete (#15431) 2022-08-15 23:42:57 +03:00
Delyan Angelov
26986eb2f8 tests: fix deprecation warning in tcp_test.v 2022-08-15 15:17:00 +03:00
yuyi
6fdcc5bcd0 checker, cgen: fix closure with fn variables (fix #15286) (#15427) 2022-08-15 06:52:08 +03:00
Emily Hudson
90d9b200f9 gc: fix msvc not using libatomic_ops (#15418) 2022-08-14 13:16:52 +03:00
Delyan Angelov
8f98f1db9e os: fix os.open_file('text.txt', 'wb', 0o666), add test (#15420) 2022-08-14 09:50:05 +03:00
Delyan Angelov
cae7bc9a9a examples: add examples/gg/rotating_textured_quad.v 2022-08-14 09:45:25 +03:00
Swastik Baranwal
7280d4c95a checker: add error for println('x').abcd (#15423) 2022-08-14 09:43:54 +03:00
Delyan Angelov
4c0339242a doc: fix example comment for string.strip_margin() 2022-08-14 08:06:52 +03:00
yuyi
9734148f12 cgen: fix generic with multi-nested generic method call ref argument (#15421) 2022-08-13 19:26:00 +03:00
StunxFS
672066b65b cgen: fix optional indexes with mutable arrays (#15399) 2022-08-13 11:58:31 +03:00
Ken
001144fa82 doc: fix a typo in the -no-preludes option description in v help build-c (#15404) 2022-08-13 10:07:08 +03:00
Joe Conigliaro
f557acf76b net.urllib: fix ipv6 address parsing [ipv6]:port closes #15309 2022-08-13 00:50:38 +10:00
StunxFS
657389446b checker: fix typo (#15397) 2022-08-12 17:25:52 +03:00
yuyi
9f2651717a checker: fix generics with multi nested generic method call (#15410) 2022-08-12 17:25:29 +03:00
Hitalo de Jesus do Rosário Souza
b45da86688 examples: refactor vweb_orm_jwt (#15389) 2022-08-12 17:24:57 +03:00
yuyi
9c96b13f9b ast: fix anon fn with nested anon fn argument (#15415) 2022-08-12 17:24:23 +03:00
yuyi
70e3c72619 ast: fix expr.str() (fix #12650 #13312) (#15414) 2022-08-12 17:24:13 +03:00
yuyi
584597aa3d checker: check mismatch of return result type (#15413) 2022-08-12 17:23:14 +03:00
yuyi
e6606d8670 cgen: fix optional in if expr (#15411) 2022-08-12 17:22:27 +03:00
Alexander Medvednikov
09f1eb9ad2 doc: make if debug a bit more clear 2022-08-12 05:10:39 +03:00
Larpon
fd83b95d85 sokol: expose context_pool_size field on sgl.Desc (#15409) 2022-08-11 20:49:11 +03:00
yuyi
9e0bf005f7 checker: simplify infer_fn_generic_types() (#15408) 2022-08-11 14:25:43 +03:00
yuyi
275a997ec1 vweb: fix vweb static url (#15396) 2022-08-11 08:28:47 +03:00
yuyi
32fa475316 markused: fix generic fn mark as used (fix #15387) (#15406) 2022-08-11 08:27:20 +03:00
Nikolai
f54e45b77e json: fix array_fixed encode/decode (#15398) 2022-08-11 03:52:56 +03:00
Markus F.X.J. Oberhumer
5095364838 cgen: avoid a compiler warning in generated code (#15394) 2022-08-11 03:52:42 +03:00
Delyan Angelov
1c6366eb9c cgen: fix generated any/filter/all methods for shared array fields 2022-08-10 14:05:33 +03:00
yuyi
78d0255e6c checker: fix generics with nested generic method call (#15390) 2022-08-10 11:29:19 +03:00
Delyan Angelov
c752e5eb3e checker: add a suggestion for misspelled field names in struct literals 2022-08-10 11:01:43 +03:00
yuyi
d3aa7700c7 cgen: fix shared struct method call (#15386) 2022-08-09 12:44:19 +03:00
yuyi
7be9963a41 checker: fix dumping generic fn mut argument (#15384) 2022-08-09 07:46:55 +03:00
yuyi
d4b622bdc2 checker: add pref.is_verbose for print_backtrace (#15385) 2022-08-09 07:43:59 +03:00
Spydr
27c5ad03f6 native: initial linking support for linux (#15326) 2022-08-08 22:32:14 +03:00
StunxFS
a6026fd505 checker: disallow method calls with invalid expressions (#15337) 2022-08-08 17:35:24 +03:00
yuyi
9b88feccad checker: check generic method call argument mismatch (#15378) 2022-08-08 17:30:48 +03:00
Delyan Angelov
5a834a2ef9 encoding.base58: remove one unnecessary map access per the most common BTC usages; implement encode_bytes, decode_bytes, encode_walpha_bytes, decode_walpha_bytes functions 2022-08-08 15:37:00 +03:00
yuyi
6a728e1674 cgen: fix shared array.last() (#15379) 2022-08-08 13:11:38 +03:00
yuyi
c7152a6ab6 checker: fix generics with nested generic fn call (#15361) 2022-08-08 04:54:52 +03:00
Hitalo de Jesus do Rosário Souza
ee9142a113 examples: V orm still fast? (#15330) 2022-08-08 04:38:38 +03:00
jrfondren
0b1486f014 http: avoid costly string interpolation of resp.body (#15376) 2022-08-08 04:36:45 +03:00
Ikko Ashimine
d74cf084fb readme: fix a typo (#15373) 2022-08-08 03:01:05 +03:00
Vincenzo Palazzo
b01f71d9da io: migrate the Reader API to Result instead of Option (#15229) 2022-08-08 02:33:25 +03:00
l-m
8c33a40c5a vrepl: implement the 'pin' command from crepl (#15371) 2022-08-07 14:06:50 +03:00
Emily Hudson
fd1b6efea6 net: add failed addresses + details on connect errors, make connect more robust in the default non blocking mode (#15364) 2022-08-07 10:40:05 +03:00
Swastik Baranwal
d6b594c4e8 checker: check if struct field type isn't type (#15359) 2022-08-06 19:11:51 +03:00
yuyi
8d9af2e4a1 cgen: fix nested generic fn call with reference argument (#15353) 2022-08-06 19:07:33 +03:00
Delyan Angelov
4588bb44ab markused: skip panic_result_not_set (generated for fn main(){ foo()! }) too 2022-08-06 10:29:44 +03:00
cstffx
095f4bcf86 orm: add missing 'nonull' attribute description (#15348) 2022-08-05 10:27:19 +03:00
yuyi
ab244d2236 checker: cleanup in if_expr() (#15347) 2022-08-05 03:02:22 +03:00
yuyi
9e50803071 ast, parser: fix reference typenode (#15346) 2022-08-05 03:01:49 +03:00
yuyi
e034b35144 cgen: fix generic interface call with reference argument (#15345) 2022-08-05 03:01:11 +03:00
yuyi
d7a3b866ee checker: check generic interface missing type parameter (#15344) 2022-08-04 11:02:34 +03:00
Hitalo de Jesus do Rosário Souza
161ac3434f examples: serve js (#15246) 2022-08-03 13:34:26 +03:00
yuyi
372857c19c checker: minor cleanup in struct_decl() (#15325) 2022-08-03 13:28:53 +03:00
yuyi
2ad25f6d06 checker: fix nested generic fn call (fix #15328) (#15333) 2022-08-03 13:24:39 +03:00
Delyan Angelov
77495c8d03 all: support assert condition, extra_message, evaluating and showing extra_message on assert failure (#15322) 2022-08-03 01:14:01 +03:00
Subhomoy Haldar
fcde63127f rand: fix incorrect generic function call (#15327) 2022-08-02 20:11:49 +03:00
Sandro Martini
51ef8b62ba log: cleanup tests (#15320) 2022-08-02 18:01:49 +03:00
Spydr
867f500d78 gitignore: ignore valgind vgcore.* debug files (#15321) 2022-08-02 17:59:29 +03:00
Delyan Angelov
45c601b79c cgen: fix sorting of shared array fields (fix #15244) 2022-08-02 16:17:11 +03:00
Delyan Angelov
857e047d01 json: tag functions that cgen may call internally for json.encode/json.decode, as [markused] 2022-08-02 11:45:41 +03:00
Nacho Verdón
42efc383d2 encoding.binary: fix function names in comments (#15317) 2022-08-02 00:30:06 +03:00
Nacho Verdón
0555894e7f .github: Add example on PR template title to avoid confusion (#15311) 2022-08-01 23:29:04 +03:00
yuyi
ce59fffb53 scanner: make scan_all_tokens_in_buffer() private (#15312) 2022-08-01 23:15:56 +03:00
yuyi
7546d1450c scanner: minor optimization (#15313) 2022-08-01 23:09:27 +03:00
Spydr
dab8159b56 native: implement elf section types (#15316) 2022-08-01 23:04:59 +03:00
Delyan Angelov
a35356758c log: make set_level(level Level) part of the log.Logger interface too (fix for discordv) 2022-08-01 15:09:32 +03:00
StunxFS
b08690d151 gen.c: simplify unwrap_generic method (#15288)
* gen.c: use `nil` instead of `0`
* replace `muttable` => `mut_table`
2022-08-01 11:40:37 +03:00
Spydr
b4fd9b5f92 native: add sections for string- and symbol-tables, reimplement elf program headers (#15305) 2022-08-01 10:15:06 +03:00
Nacho Verdón
9561fb406e encoding.binary: add functions to read/write with an offset and at the end of the array, split files by endianness (#15301) 2022-08-01 08:20:14 +03:00
Dialga
dc78f1ba17 szip: update to 0.2.4 (#15296) 2022-08-01 00:47:45 +03:00
Delyan Angelov
fa75713bc3 tools: create the vmodules folder, when it does not exist, on v translate hw.c 2022-07-31 15:43:04 +03:00
Delyan Angelov
b8438ded32 markused: support vweb App.before_request() with -skip-unused 2022-07-30 18:56:05 +03:00
yuyi
014f44eab3 checker: improve error message of method_call_arg_no_mut_err.vv (#15281) 2022-07-30 18:11:10 +03:00
Davide Beatrici
c9a5896468 bultin: always enable GC_THREADS, even with -d dynamic_boehm, otherwise multithread operation is unsafe (#15275)
According to upstream documentation, only GC_WIN32_THREADS is explicit.

This PR fixes a random memory corruption(s) with "-d dynamic_boehm" on OpenMandriva.
1679adc04d.log
```
DEBUG: + VFLAGS='-prod -d dynamic_boehm'
DEBUG: + /usr/bin/clang -Os -fomit-frame-pointer -g3 -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-all --param=ssp-buffer-size=4 -m64 -mtune=generic -flto -std=gnu99 -w -o tmp_1 v.c -lm -lpthread -Os -fomit-frame-pointer -g3 -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-all --param=ssp-buffer-size=4 -m64 -mtune=generic -flto -Wl,-O2 -Wl,--no-undefined -flto
DEBUG: + ./tmp_1 -no-parallel -o tmp_2 -prod -d dynamic_boehm cmd/v
DEBUG: + ./tmp_2 -o v -prod -d dynamic_boehm cmd/v
DEBUG: /var/tmp/rpm-tmp.mcjmqc: line 52:   644 Bus error               (core dumped) ./v build-tools
```
2022-07-30 14:59:12 +03:00
yuyi
db79888daf picoev: restore struct Picoev definition (#15278) 2022-07-30 14:30:13 +03:00
yuyi
6e8350a9c9 fmt: fix interface method with fntype argument (#15280) 2022-07-30 14:29:41 +03:00
yuyi
e6a04905e9 fmt: fix comptime method call (#15279) 2022-07-30 14:28:34 +03:00
yuyi
b6ce7cc198 checker: check invalid variable (fix #15240) (#15260) 2022-07-30 14:27:28 +03:00
Delyan Angelov
0133ff2cbf checker: use reserved_type_names_chk.matches(word) instead of word in reserved_type_names 2022-07-29 23:23:34 +03:00
Delyan Angelov
f0a8d57735 checker: use array_builtin_methods_chk.matches(method_name) instead of method_name in array_builtin_methods 2022-07-29 23:23:34 +03:00
Delyan Angelov
336305daa5 scanner,parser,gen: use km.matches(word) instead of km.find(word) != -1 2022-07-29 23:23:33 +03:00
Delyan Angelov
2db8bd62a2 token: fix a new_keywords_matcher_from_array_trie bug (first word with idx 0 was ignored); add tests 2022-07-29 23:23:33 +03:00
Delyan Angelov
a42eb3b947 cgen: use a trie matcher for c_reserved checks as well 2022-07-29 23:23:32 +03:00
zakuro
8268df7e1d parser: create and use Parser.unexpected to unify all unexpected token error messages (#15259) 2022-07-29 19:28:34 +03:00
yuyi
1be595605a parser: fix optional fn argument (#15271) 2022-07-29 19:10:50 +03:00
yuyi
0bf23488dc checker: check struct field's fn call (fix #15249) (#15257) 2022-07-29 19:00:51 +03:00
lemon
927ec1fadb native: support ||, && and simple boolean expression evaluation (#15256) 2022-07-29 07:17:01 +03:00
Delyan Angelov
04b28d11be cgen: use switch for matches with integer literals, instead of an if else if ladder (#15254) 2022-07-29 00:36:29 +03:00
yuyi
17ce1a0e8d parser: check undefined ident in if guard expr (#15253) 2022-07-28 19:13:41 +03:00
Delyan Angelov
242ade8938 os: fix File.eof on FreeBSD (feof is a C macro there) 2022-07-28 17:26:55 +03:00
Reuben Thomas
ed56c3957e os: add File.reopen and File.eof methods (#15184) 2022-07-28 16:21:23 +03:00
Tim Dupont
3d0a48b1bb CHANGELOG.md: fix for a small typo (paramter -> parameter) (#15252) 2022-07-28 14:16:33 +03:00
Dialga
18ae726015 v.pkgconfig: add the default path for Debian 32bit (#15250) 2022-07-28 14:06:56 +03:00
Delyan Angelov
a16f9ac41f mysql: include workaround for windows programs that just exit, when the libmysql.dll is not found, into vlib/mysql/README.md 2022-07-27 22:26:36 +03:00
l-m
10f3c9f127 builtin: add string.replace_char and string.normalize_tabs (#15239) 2022-07-27 22:04:39 +03:00
yuyi
60094d95e2 cgen: check comptime call method (no value) used as value (#15241) 2022-07-27 21:32:00 +03:00
Davide Beatrici
8af87a9e98 make: rename "V" to "VEXE" in GNUmakefile, to prevent conflicts while building RPMs (#15237)
This fixes a build failure when using "%make_build" in an RPM spec file:

make: 1: No such file or directory
make: *** [GNUmakefile💯 all] Error 127
2022-07-27 21:04:29 +03:00
yuyi
6a7eb82d9e cgen: fix comptime for method call with arguments (#15236) 2022-07-27 03:22:05 +03:00
stringnick
afaab7ab4d stdatomic: add/sub return result of op (#15235) 2022-07-27 03:21:03 +03:00
Hitalo de Jesus do Rosário Souza
e5e750d533 orm: default attribute (#15221) 2022-07-27 00:59:32 +03:00
yuyi
c976a691ad scanner: correct error message of empty character literal (fix #15226) (#15228) 2022-07-26 15:07:08 +03:00
Bastian Buck
4ab72ccb69 os: add a security advisory for potential TOCTOU risks when using os.is_writable, os.is_executable etc (#15222) 2022-07-26 12:02:48 +03:00
yuyi
03b7c76b38 cgen: optimize auto_str_methods of [str:skip] fields (#15227) 2022-07-26 09:38:50 +03:00
yuyi
0b0c496eff cgen: fix printing struct with skip fields (#15224) 2022-07-26 04:37:16 +03:00
Alexander Medvednikov
f1ebfb2d42 cgen: str:skip field 2022-07-25 17:25:47 +03:00
Alexander Medvednikov
5a3a145e99 gg: fix native draw_circle on macos 2022-07-25 17:25:47 +03:00
yuyi
f619becbdc scanner: check undefined ident in string literal (#15212) 2022-07-25 14:28:47 +03:00
Hitalo de Jesus do Rosário Souza
82db1e4746 pg: improve pg README.md (#15206) 2022-07-25 08:32:21 +03:00
Tim Richardson
7bf2ad6889 vscode.md: fix typo (#15207) 2022-07-25 08:04:06 +03:00
Andrew Compton
f9385f6300 os: make get_raw_line() should not break lines on \r on windows (fix #5900) (#15205) 2022-07-25 08:03:07 +03:00
Delyan Angelov
6a5db0df61 v.token: use a more performant KeywordMatcher in the scanner and parser (#15196) 2022-07-25 06:32:06 +03:00
Subhomoy Haldar
297cb5f89c math.big: improve multiplication performance (#15200) 2022-07-24 19:35:37 +03:00
Hitalo de Jesus do Rosário Souza
2d7406a8cd examples: v back-end example for vweb (#15141) 2022-07-24 13:02:57 +03:00
Hitalo de Jesus do Rosário Souza
1f3be99859 crypto: add an example of how to verify jwt tokens (#15198) 2022-07-24 10:27:21 +03:00
yuyi
5464de406c cgen: fix custom str on struct with too many fields (#15195) 2022-07-24 10:15:22 +03:00
Delyan Angelov
de0683fe30 tests: fix compilation of tcp_test.v 2022-07-23 23:33:43 +03:00
Delyan Angelov
c63fed5393 tests: remove needless import math in translated_test.v 2022-07-23 23:24:17 +03:00
Alexander Medvednikov
d8b0df1a31 doc: fix ci 2022-07-23 01:55:17 +03:00
Alexander Medvednikov
d6de53362f checker: improve unused label check 2022-07-23 01:36:27 +03:00
Alexander Medvednikov
4d3401c852 checker: check for unused labels 2022-07-23 01:25:20 +03:00
Alexander Medvednikov
af41058979 doc: map ordering 2022-07-23 00:53:42 +03:00
Reuben Thomas
2ffad85f06 doc: remove misleading comment about stdin() (#15154) 2022-07-23 00:22:50 +03:00
yuyi
b0c32e0dbf checker: fix fn variadic with enum value (#15177) 2022-07-22 16:08:22 +03:00
yuyi
092f5f0bf8 checker: fix comptime if in const declaration (fix #15160) (#15169) 2022-07-22 16:03:45 +03:00
zakuro
9ec8a99243 parser: cleanup orblock duplicate code (#15173) 2022-07-22 12:36:50 +03:00
Delyan Angelov
e9809572b1 ast: use const empty_expr instead of fn empty_expr (thanks to Joe Conigliaro for the idea) (#15175) 2022-07-22 12:14:46 +03:00
Delyan Angelov
c6aea659e3 cgen,ci: fix v -usecache self on macos 2022-07-22 11:43:20 +03:00
Delyan Angelov
f75d7eb114 ci: fix v build-examples (use voidptr(u64(0)) inside vlib/js/dom/dom.js.v) 2022-07-21 23:08:18 +03:00
Delyan Angelov
5340f8afea ci: fix vlib/v/checker/tests/nil.vv and its .out file 2022-07-21 23:05:02 +03:00
Delyan Angelov
474033c055 ci: allow unsafe { a := nil }, add separate nil case in pointer_ops.vv, to test the nil checker errors independently from the voidptr ones 2022-07-21 22:52:38 +03:00
Delyan Angelov
697d546d46 ci: fix fixed_array_conv.out output (the .vv file was formatted) 2022-07-21 22:45:54 +03:00
Delyan Angelov
cf42ba2b80 ci: revert nil to voidptr(u64(0)) in voidptr_dereference_err.vv too. nil should have its own .vv/.out pair. 2022-07-21 22:43:14 +03:00
Delyan Angelov
cdefb878d6 ci: make pass_voidptr_as_interface_reference_test.v use voidptr again 2022-07-21 22:41:27 +03:00
Delyan Angelov
2e89eeb477 ci: make voidptr_casted_as_an_interface_test.v use voidptr again (it does test exactly that edge case, it should not have been converted to use nil) 2022-07-21 22:40:21 +03:00
Delyan Angelov
71cd256f0c ci,cgen: fix -usecache compilation of V itself 2022-07-21 22:29:44 +03:00
Delyan Angelov
73b02cdf36 ci: fix spurious native_backend_tests.yml cancellations 2022-07-21 22:13:21 +03:00
Delyan Angelov
81104ac309 ci: fix v test-cleancode failures 2022-07-21 22:05:17 +03:00
Delyan Angelov
231623b75b ci: vfmt tcp_test.v 2022-07-21 22:04:51 +03:00
Delyan Angelov
dc1b54c669 ci: fix failing ./v vlib/builtin/builtin_test.v (globals initialisation) 2022-07-21 21:49:00 +03:00
Delyan Angelov
ed43bfc469 ci: fix dlmalloc again (workaround vfmt) 2022-07-21 21:21:20 +03:00
Delyan Angelov
e29f6d1393 markused: fix ./v -skip-unused -cc gcc -keepc -freestanding -o bel vlib/os/bare/bare_example_linux.v 2022-07-21 21:18:33 +03:00
Delyan Angelov
d9fe2edc41 ci: fix failing build-module-docs (because of unsafe { unsafe { nil } }) 2022-07-21 21:11:43 +03:00
Delyan Angelov
6ebe668a74 tools: show the exact failing c2v command on v translate failure for easier diagnostic/debugging. 2022-07-21 21:04:06 +03:00
Alexander Medvednikov
9099594a49 all: wrap up unsafe { nil } (p. 3) 2022-07-21 21:01:30 +03:00
Alexander Medvednikov
a68d03ac59 checker: allow x := unsafe { nil } 2022-07-21 20:56:24 +03:00
Alexander Medvednikov
dc79f1392b all: voidptr(0) => unsafe { nil } (p.2) 2022-07-21 20:51:54 +03:00
Alexander Medvednikov
1f25811786 roadmap: update 2022-07-21 20:47:30 +03:00
Alexander Medvednikov
caa0c2f153 vfmt: voidptr(0) => unsafe { nil } (p.1) 2022-07-21 20:46:01 +03:00
yuyi
be9f8cc777 cgen: fix comptime if in struct field default (fix #15058) (#15152) 2022-07-21 16:59:18 +03:00
yuyi
7029e39088 checker: check struct field with default expression (#15151) 2022-07-21 10:33:34 +03:00
Joe Conigliaro
49228e1acd cgen: fix dep cycle for struct Node { children [4]&Node } closes #15136 2022-07-21 16:16:24 +10:00
Delyan Angelov
8593408179 json.cjson: add a submodule that allows lower level access to the cJSON library (constructing JSON trees in memory with null leafs). 2022-07-20 23:34:17 +03:00
Hitalo de Jesus do Rosário Souza
c8d4534f5b sqlite: remove spurious eprintln on select calls (#15139) 2022-07-20 17:35:38 +03:00
Ned
57a201f28c tools: add helpful message, when the vls server executable is not found on v ls (#15129) 2022-07-20 14:26:49 +03:00
kahsa
9995063304 doc: add a go fn() {} example (#15134) 2022-07-20 14:24:13 +03:00
yuyi
f27c0387ad cgen: minor cleanup in global_decl() (#15133) 2022-07-20 13:51:33 +03:00
Delyan Angelov
ee4a179e71 tests: add a test for Node{123, unsafe { nil }, unsafe { nil }} 2022-07-20 11:29:01 +03:00
Delyan Angelov
50075d5a79 ast,cgen: support a := Abc{unsafe{nil}}, for struct Abc { next &Abc } 2022-07-20 10:47:04 +03:00
Fossean1
1ccb4c3ac0 doc: minor fixes in examples (#15125) 2022-07-19 20:59:59 +03:00
Hitalo de Jesus do Rosário Souza
a13b8ff0c8 mysql: fix for adapting mysql types to v structs (#15100) 2022-07-19 18:29:09 +03:00
yuyi
041e90b2e2 checker, cgen: fix interface embedding smartcast (fix #13296) (#15127) 2022-07-19 16:36:16 +03:00
Alexander Medvednikov
0afa2f76c8 ci: fix gitly ci 2022-07-19 13:53:05 +03:00
Alexander Medvednikov
fd47385ff2 checker: check untyped nil in assignment 2022-07-19 13:31:10 +03:00
Alexander Medvednikov
1aeca113d3 sokol: do not crash if an image cannot be rendered 2022-07-19 13:21:34 +03:00
SakthiMahendran
e4674cb8e1 examples: replace "resp.text" with "resp.body". (#15123) 2022-07-19 12:52:42 +03:00
yuyi
a39fe68af1 cgen: clean up ident() in cgen.v (#15121) 2022-07-19 10:54:03 +03:00
Ned
c7ec71cd06 tools/vls: skip 'ls' argument on v ls (#15126) 2022-07-19 10:52:39 +03:00
Larpon
02925cecd1 ci: fix report-missing-fn-doc (#15118) 2022-07-18 22:33:18 +03:00
Mehmet Ali
12d57e8e7b sokol: add mouse cursor support (#15111) 2022-07-18 09:44:48 +03:00
Zhomart Mukhamejanov
c1502b3c1f examples: add macos_tray example app (#15101) 2022-07-18 09:42:45 +03:00
yuyi
5462d4aebf checker: check generic interface declaration (#15108) 2022-07-18 01:36:37 +03:00
penguindark
706a922e0c x.ttf: update to fix compilation of vlang/pdf and failing ci (#15109) 2022-07-17 19:44:11 +03:00
yuyi
eed496d0bc checker: check generic struct declaration (#15106) 2022-07-17 18:09:15 +03:00
Spydr
368cccb059 native: add typechecking to gen_var_to_string() (#15107) 2022-07-17 18:09:03 +03:00
Spydr
c73c4dc884 native: system for defining internal builtin algorithms which are not inlined (#15105) 2022-07-17 16:22:54 +03:00
yuyi
58ad6f7999 checker: check generic fn declaration (#15104) 2022-07-17 14:32:59 +03:00
yuyi
78242627c3 parser: fix fn argument type position (#15102) 2022-07-17 10:55:20 +03:00
Ken
3075e35237 encoding.csv: handle bools (#15103) 2022-07-17 10:54:36 +03:00
boris-741
b4dedcae43 encoding.csv: generic serialization (#15097) 2022-07-16 22:21:05 +03:00
yuyi
8d24522d02 parser: check generic interface method declaration (#15095) 2022-07-16 16:58:39 +03:00
Delyan Angelov
5e0899853b dlmalloc: fix warning about fixed arrays of references, by using unsafe{} 2022-07-16 16:37:20 +03:00
Delyan Angelov
bd4e9f6225 v: offer a suggestion for misspelled commands like v held 2022-07-16 14:58:26 +03:00
Delyan Angelov
b01df8ed0a help: chmod 644 cmd/v/help/where.txt 2022-07-16 12:45:08 +03:00
yuyi
ac7e809464 checker: fix generics struct init in generic fn (fix #15080) (#15088) 2022-07-15 17:30:56 +03:00
yuyi
560afac5d5 cgen: fix fixed array of threads (#15086) 2022-07-15 14:19:11 +03:00
lemon
f2961ec862 native: refer to types to generate code (#15077) 2022-07-15 14:18:32 +03:00
yuyi
57c4188d98 ast, checker: check generic fn declaration error (#15079) 2022-07-15 14:18:06 +03:00
shove
b4ed5d5f20 net: add a net.dial_tcp_with_bind/2 function (#15055) (#15056) 2022-07-15 12:38:17 +03:00
Sebastian Atlántico
4f997feee7 tools: add tests for v where; improve usability (#15059) 2022-07-15 07:59:11 +03:00
Alexander Medvednikov
89a757aba0 doc: clean up 2022-07-14 11:10:15 +03:00
Alexander Medvednikov
8d0fe3894a doc: document anonymous structs 2022-07-14 11:06:10 +03:00
yuyi
0d6d6f7de8 cgen: fix fixed array literal index (fix #14959) (#15054) 2022-07-14 08:23:29 +03:00
Alexander Medvednikov
a38310f929 checker: array of references check 2022-07-14 00:58:14 +03:00
Sebastian Atlántico
47b5d206a6 cmd/tools: vwhere fixes (#15051) 2022-07-13 18:04:26 +03:00
Hitalo de Jesus do Rosário Souza
3f3742122f orm: sql type in struct by attribute (#14919) 2022-07-13 18:03:30 +03:00
Hunam
4238e5f6b9 roadmap: update (#15038) 2022-07-13 10:04:27 +03:00
yuyi
7594157deb checker: check generic interface declaration (#15047) 2022-07-13 09:43:54 +03:00
Sebastian Atlántico
28fd17654e tools: add a v where fn join_path command, for platform independent searching the location of a symbol in the local project, vlib, ~/.vmodules (#15014) 2022-07-13 07:40:54 +03:00
wilesun
d12a8aef68 json: use C.cJSON_free, for freeing the intermediate result in json_print and json_print_pretty (#15029) 2022-07-13 07:11:18 +03:00
Jun
16a6972e2a readme: fix vinix screenshots (#15041) 2022-07-13 01:13:45 +03:00
yuyi
19d0d758c9 cgen: fix struct shared field with default init (#15040) 2022-07-12 20:04:06 +03:00
yuyi
7a17a29952 examples: fix typo in c_interop_wkhtmltopdf.v (#15036) 2022-07-12 19:42:55 +03:00
yuyi
9839ab6a6c parser: fix parse c function with optional argument name (fix #13234) (#15037) 2022-07-12 11:06:29 +03:00
Delyan Angelov
b59e6b1d06 ci: do periodic runs only in the main V repository (not in forks) 2022-07-12 11:03:59 +03:00
Delyan Angelov
662d0a3ef2 ci: change ci_bootstrapping_works.yml to a periodic run, *only* on the main repository. 2022-07-12 11:02:51 +03:00
Delyan Angelov
a4e0e0fa57 builtin: add drafts for __new_array_noscan, __new_array_with_default_noscan, __new_array_with_array_default_noscan for array_notd_gcboehm_opt.v 2022-07-12 10:00:58 +03:00
yuyi
62d800a775 checker, cgen: fix array of sumtype appending alias (#15034) 2022-07-12 09:26:11 +03:00
Subhomoy Haldar
8a4313c1b8 ci: fix vlib/v/builder/builder_test.v failures on msvc (#15035) 2022-07-12 08:46:59 +03:00
Dmitriy Smirnov
f35a3a89f9 checker: fix dereferencing voidptr. (#15033) 2022-07-12 01:12:29 +03:00
Subhomoy Haldar
dc68469818 use trimmed output for comparison (#15032) 2022-07-11 22:47:32 +03:00
Subhomoy Haldar
fbad48b5d9 v.builder: retain executable after v run, if the executable was already existing (#15021) 2022-07-11 21:08:53 +03:00
Delyan Angelov
f16355eeba ci: fix build failure (complete renaming in 39b6851) 2022-07-11 20:59:37 +03:00
yuyi
39b68518b2 checker: minor refactor in infix_expr() (#15028) 2022-07-11 20:16:42 +03:00
shove
032cb3f115 checker: fix the type of ComptimeCall (fixes #14996) (#15013) 2022-07-11 20:08:01 +03:00
yuyi
398bd2280d cgen: fix printing reference alias (#15027) 2022-07-11 20:04:34 +03:00
yuyi
ec19f4289c checker, cgen: fix alias operator overloading (#15024) 2022-07-11 19:20:15 +03:00
yuyi
9231697966 parser: check for illegal use of any type (fix #15003) (#15020) 2022-07-11 15:29:25 +03:00
Delyan Angelov
5498a6c263 tests: add more -skip-unused cases to v test-all 2022-07-11 11:02:17 +03:00
Delyan Angelov
94e35b710c markused: fix C compilation failures on -skip-unused -profile 2022-07-11 10:56:13 +03:00
yuyi
81d694b1f8 tests: restore interfaces_map_test (#15019) 2022-07-11 09:05:36 +03:00
yuyi
a6cc4c4c28 parser: minor cleanup in parse_type.v (#15011) 2022-07-11 08:03:08 +03:00
yuyi
7ff20c09ca tests: restore test_interface_struct_from_mut_array() (#15018) 2022-07-11 07:57:14 +03:00
Ned
a331cf577a tools/vls: fix installing vls when config is not present (#15017) 2022-07-11 07:56:53 +03:00
yuyi
cc43a23f29 vweb: check invalid port number (#15016) 2022-07-11 07:55:33 +03:00
Alexander Medvednikov
bfcf5b13ed checker: fix #define check on windows 2022-07-11 00:20:12 +03:00
Alexander Medvednikov
22dac71b33 checker: do not allow #define everywhere 2022-07-10 22:51:06 +03:00
Ned
235ef23588 tools: add v ls - a VLS launcher and updater utility (#15009) 2022-07-10 20:27:50 +03:00
yuyi
58c5d387c4 parser: check closure capture global variable (#15010) 2022-07-10 20:21:54 +03:00
Delyan Angelov
3549055548 ci: use v should-compile-all sdl/examples/ instead of the bash script that choked on v sdl/examples/assets 2022-07-10 20:05:04 +03:00
Delyan Angelov
3b575e83f1 ci: fix ./v cmd/tools/builders/golang_builder.v 2022-07-10 18:53:18 +03:00
Delyan Angelov
01dabe5966 ci: fix failing invalid_struct_decl_script_err.vv 2022-07-10 18:37:42 +03:00
Delyan Angelov
5d8d11c989 ci: fix v cmd/tools/vast after ast.StructInit field renaming 2022-07-10 18:28:24 +03:00
Delyan Angelov
d15e9f4866 ci: remove forgotten dump call 2022-07-10 17:05:49 +03:00
Delyan Angelov
69aaf68f2f cgen: fix anon struct auto string method generation 2022-07-10 16:57:13 +03:00
yuyi
64eab72f4c checker: fix anon fn using global variable (fix #15004) (#15008) 2022-07-10 12:43:50 +03:00
Alexander Medvednikov
7d0a9186bb all: wrap up anonymous structs 2022-07-10 12:00:17 +03:00
Ken
1ae11b41e7 net.websocket: make logger configurable (#14998) 2022-07-09 17:39:07 +03:00
Thomas Peißl
739f3cd90b pref: detect termux more reliably (#15001) 2022-07-09 17:23:19 +03:00
Subhomoy Haldar
8ee614d3f8 encoding.binary: add unit tests and module documentation (#15000) 2022-07-09 15:52:19 +03:00
Hitalo de Jesus do Rosário Souza
d4b0ebf215 doc: clear the explanation to 'sql: type' (#14915) 2022-07-09 14:04:35 +03:00
Delyan Angelov
f56aaa1007 examples: simplify examples/websocket/ping.v (end automatically, when the client ends) 2022-07-09 12:40:52 +03:00
CC
7e1c45ab44 math: add round_sig function for f64 (#14997) 2022-07-09 10:41:58 +03:00
shove
c5a290ffc6 cgen: fix lost return in ComptimeCall (fixes #14962) (#14995) 2022-07-09 08:55:01 +03:00
Alexander Medvednikov
70890b27a5 cgen: handle default anonymous structs 2022-07-08 15:40:57 +03:00
Emirhan Yener
1a49db4ea1 examples: remove empty comments (#14986) 2022-07-08 15:35:45 +03:00
Delyan Angelov
02d675ab67 os: restore the env TERMUX_VERSION based final resort for runtime auto detection of Termux 2022-07-08 11:16:53 +03:00
StunxFS
bcaa3ac915 vlib: remove jsdom module, use js.dom instead (#14985) 2022-07-08 09:23:10 +03:00
penguindark
df4bd88d45 x.ttf: fix a bug in TTF fixed point data management (#14987) 2022-07-08 09:20:59 +03:00
yuyi
5aa6ec0693 cgen: fix error for comptime method call (#14992) 2022-07-08 09:18:49 +03:00
Delyan Angelov
5f140fe2ff ci: v fmt -w vlib/v/builder/cc.v 2022-07-07 23:57:21 +03:00
StunxFS
9376009c39 v.eval: support panic function (#14972) 2022-07-07 20:00:59 +03:00
CC
6b597a4b58 builder: add support for icc (Intel C Compiler) (#14975) 2022-07-07 19:48:07 +03:00
yuyi
758f84fa86 ast, parser, cgen: fix anon sumtype cast (fix #14967) (#14976) 2022-07-07 18:51:57 +03:00
yuyi
029d583bb2 cgen: a minor fix in match_expr (#14983) 2022-07-07 18:51:27 +03:00
Larpon
9f3b6e3e3a android: provide more predictable logging, add comptime termux support (#14984) 2022-07-07 18:28:29 +03:00
Delyan Angelov
71a85249ea ci: fix failing ./v -W build-tools 2022-07-07 18:22:21 +03:00
Alexander Medvednikov
f5001192f9 fmt: handle anon structs; tests: bring back anon struct test 2022-07-07 16:11:13 +03:00
zakuro
972bba66d1 checker,ast: clean up deprecation code (#14980) 2022-07-07 15:45:45 +03:00
Delyan Angelov
de77114593 eval: support assignment operators like +=, make for a in 0..10 { more robust 2022-07-07 15:13:22 +03:00
Alexander Medvednikov
15ce15d41b tests: disable anon struct test for now 2022-07-07 13:08:10 +03:00
Delyan Angelov
91acd0f380 ci: fix failing v check-md vlib/sqlite/README.md 2022-07-07 13:05:05 +03:00
Alexander Medvednikov
7da466e81b parser: show a hint when using v . with multiple fn mains 2022-07-07 13:04:08 +03:00
Alexander Medvednikov
426421bebb all: anonymous structs (part 2) 2022-07-06 21:38:45 +03:00
yuyi
f4b39fbe4f cgen: fix sumtype with none (#14965) 2022-07-06 21:03:42 +03:00
CC
d86b4951c7 sqlite: add sync and journal funcs, docs (#14970) 2022-07-06 21:01:27 +03:00
Delyan Angelov
f0ce7fb9d3 Revert "gg: fix android compilation for ~/.vmodules/ui/examples/rectangles.v"
This reverts commit f1a855e6d2.
2022-07-06 16:19:40 +03:00
Delyan Angelov
f1a855e6d2 gg: fix android compilation for ~/.vmodules/ui/examples/rectangles.v 2022-07-06 16:02:50 +03:00
Delyan Angelov
82f7597a0c ci: fix failing v check-md doc/docs.md 2022-07-06 15:52:18 +03:00
Delyan Angelov
3308313167 os: remove the closing of stream handles at the end of Process.win_slurp/1 2022-07-06 15:43:13 +03:00
zakuro
a46bcf3571 all: v.ast.byte_type -> v.ast.u8_type (#14964) 2022-07-06 13:32:30 +03:00
Alexander Medvednikov
00dfce655e doc: document if as 2022-07-06 12:41:36 +03:00
CC
6a567a0dd6 sqlite: improve exec_none behaviour (#14955) 2022-07-06 10:44:36 +03:00
yuyi
bb2223c8b0 checker: fix shared_element_lock.vv test (#14960) 2022-07-06 10:43:36 +03:00
Alexander Medvednikov
59d6ca0c95 js: remove duplicate match 2022-07-06 07:46:58 +03:00
Alexander Medvednikov
819b6f475a os: remove unnecessary unsafes 2022-07-06 07:07:48 +03:00
Alexander Medvednikov
d3090de02e checker: apply the new array check only to len:, not cap: inits 2022-07-06 07:03:36 +03:00
yuyi
fab5802deb all: fix latest ci errors (#14957) 2022-07-06 07:02:16 +03:00
Alexander Medvednikov
3f3fb5be47 js: handle Nil 2022-07-06 06:47:37 +03:00
Alexander Medvednikov
c48ed52f43 checker: vfmt 2022-07-05 23:56:53 +03:00
Alexander Medvednikov
163c7ba2bb checker: stricter []&Type{len:x} check 2022-07-05 23:51:29 +03:00
Alexander Medvednikov
9b4dec7b98 parser: anonymous structs (part 1) 2022-07-05 23:17:00 +03:00
Alexander Medvednikov
5f78647137 all: unsafe nil 2022-07-05 22:59:54 +03:00
Larpon
9b1a616b13 ci: remove openrndr dependency from vgret testing (#14950) 2022-07-05 22:44:27 +03:00
Larpon
e08fedfd14 ci: add runtime DOOM checks via vgret (#14951) 2022-07-05 22:44:14 +03:00
Larpon
0dd5050b29 os: clean up usage of ANativeActivity, allow access to fields (#14948) 2022-07-05 16:30:10 +03:00
yuyi
56d62a6e6f checker: check undefined ident in reference selector (#14949) 2022-07-05 16:29:54 +03:00
yuyi
8b8667dd9a cgen: cleanup in fn.v (#14938) 2022-07-05 06:40:57 +03:00
Larpon
e18c5c7908 tools: add generic_screenshot method to vget (#14943) 2022-07-05 06:40:38 +03:00
Ken
a50e0f0522 net.websocket: allow timeout to be configured (#14941) 2022-07-05 06:40:23 +03:00
Alexander Medvednikov
5523c11dd4 help: remove "coming soon in 0.3" for v translate 2022-07-05 06:38:33 +03:00
Max Smirnov
3bdf2f053d changelog: fix typo (#14930) 2022-07-04 15:34:00 +03:00
Ted Stoychev
63b6923565 readme: fix header (#14933) 2022-07-04 15:33:41 +03:00
ghosttk
eb10cc9606 vweb: fix '/' in scan_static_directory (#14940) 2022-07-04 15:32:44 +03:00
Delyan Angelov
946da5556d ci: add a c2v job too, that checks that Doom compiles. 2022-07-04 14:16:14 +03:00
Delyan Angelov
e156066acf ci: fix gitly failure (compile gitly.scss to gitly.css) 2022-07-04 12:50:18 +03:00
yuyi
7f72ffdd66 cgen: fix error for result multi_return (#14936) 2022-07-04 10:54:08 +03:00
Delyan Angelov
90197fd58a term.ui: make C. unions and structs public (solve conflicts with term on windows) 2022-07-04 10:50:19 +03:00
Ikko Ashimine
584c035120 sync: fix typo in pool.v (#14928) 2022-07-03 15:24:57 +03:00
yuyi
9028b0ed76 parser: minor cleanup in partial_assign_stmt() (#14929) 2022-07-03 15:24:42 +03:00
Alexander Medvednikov
20ba2a10c1 builder: use is_dir for src/; changelog: add 0.3.1 features 2022-07-03 15:13:08 +03:00
Alexander Medvednikov
c90e8185ed builder: search for .v files in /src/ if there are none 2022-07-03 08:41:26 +03:00
Alexander Medvednikov
b5f2636b73 Revert "vweb: remove the extra '/' in scan_static_directory (#14806)"
This reverts commit 8172fecb51.
2022-07-02 11:38:24 +03:00
Dialga
6957f940a0 pkgconfig: fix parsing mid-line comments (#14920) 2022-07-02 11:31:52 +03:00
Joe Conigliaro
4032838aba gen.golang: array append & basic strings 2022-07-02 17:07:47 +10:00
Claudio Cesar de Sá
5b97ad15ad examples: add new graph algorithms, make some minor corrections to the programs in examples/graphs (#14562) 2022-07-01 21:37:00 +03:00
CC
dc9ff7cab2 README: add TCC acknowledgement (#14910) 2022-07-01 21:10:36 +03:00
Alexander Medvednikov
f0cee25213 Update README.md 2022-07-01 16:50:51 +03:00
yuyi
1b463834aa builder: fix cross compiling for linux on windows (fix #6241, fix #12922) (#14907) 2022-07-01 15:24:27 +03:00
Delyan Angelov
69d292e8d1 os: detect termux more reliably 2022-07-01 13:52:57 +03:00
Delyan Angelov
b6b611aa82 v: support better separation of general Android vs Termux specific code (part 2) 2022-07-01 13:18:31 +03:00
Delyan Angelov
30401e003f v: support better separation of general Android vs Termux specific code (part 1) 2022-07-01 12:48:35 +03:00
CC
ff0f75803d docs: add a note on how to install gcc-mingw-w64-x86-64 needed for linux->windows cross compilation (#14905) 2022-07-01 08:25:06 +03:00
Emirhan Yener
71ff221cff gg: update draw polygon test (#14880) 2022-06-30 21:21:12 +03:00
Hunam
e4a49d5dd5 doc: update ROADMAP.md (#14897) 2022-06-30 21:20:34 +03:00
yuyi
d3c1e671f1 fmt: minor optimization in struct.v (#14898) 2022-06-30 19:52:49 +03:00
ylluminate
3f147cbc38 CHANGELOG.md: fix the 0.2.4 heading (#14900) 2022-06-30 19:51:22 +03:00
Markus F.X.J. Oberhumer
74bb5ae17a os: add an optional "mode" parameter to os.mkdir and os.mkdir_all (#14887) 2022-06-30 13:49:47 +03:00
Larpon
7c3571b274 sokol: allow thirdparty window control (#14896) 2022-06-30 13:47:59 +03:00
Alexander Medvednikov
ec75860453 V 0.3 2022-06-30 10:41:25 +03:00
yuyi
9f59dbd319 fmt: fix import module { Foo } (#14894) 2022-06-30 09:48:39 +03:00
yuyi
92f441e894 cgen: minor cleanup in str.v (#14882) 2022-06-30 04:04:12 +03:00
yuyi
f2be115f7d parser: fix the incorrect location of the type declaration name (#14879) 2022-06-29 16:14:03 +03:00
Joe Conigliaro
1b0754e4f3 gen.golang: correct use of const github_job 2022-06-29 21:15:46 +10:00
Joe Conigliaro
c3866bb7b1 gen.golang: skip tests only on ubuntu-docker-musl 2022-06-29 21:11:28 +10:00
Joe Conigliaro
86549feafa gen.golang: globally skip go backend tests & run only on ubuntu-tcc 2022-06-29 20:55:43 +10:00
Joe Conigliaro
5462f06d6c gen.golang: correct error message 2022-06-29 19:09:36 +10:00
yuyi
f8461e2b3c parser: check const declaration using multiple assign (#14886) 2022-06-29 12:03:56 +03:00
ghosttk
fae26197b9 os: add exo-open to the list of tried launchers in os.open_uri/1 (#14884)
Add 'exo-open' for xfce4 desktop environment.
2022-06-29 11:59:25 +03:00
Hitalo de Jesus do Rosário Souza
c481b80ec3 docs: add a jwt example to vlib/crypto/README.md (#14872) 2022-06-29 11:57:05 +03:00
Joe Conigliaro
51649b924b gen.golang: dont push run_args in run_file assignent 2022-06-29 18:54:26 +10:00
Joe Conigliaro
eec60a3018 gen.golang: add run support & testrunner 2022-06-29 18:49:53 +10:00
yuyi
3ae59a7837 checker: optimize casting sumtype error message (fix #14023) (#14877) 2022-06-28 17:13:58 +03:00
Delyan Angelov
b47d35a0bb ci: compile golang_builder.v without warnings (fix v -prod build-tools) 2022-06-28 15:00:54 +03:00
Delyan Angelov
2bcbd0b636 ci: comment unused import strings 2022-06-28 14:16:39 +03:00
Delyan Angelov
6165b119f6 scanner,parser,checker: do show the first error on -Wfatal-errors 2022-06-28 14:05:32 +03:00
Alexander Medvednikov
64b8284419 go: remove unused code (comments) 2022-06-28 11:14:48 +03:00
yuyi
ce6bc2c26d checker: handle void in struct field init (fix #13944) (#14876) 2022-06-28 11:06:25 +03:00
Alexander Medvednikov
a4eb5b6356 gen: basic initial work on the Go backend 2022-06-28 09:41:15 +03:00
Emirhan Yener
28068e8ecf gg: add draw_polygon_filled test (#14871) 2022-06-28 08:30:45 +03:00
yuyi
42df154399 ast: add elem_type_pos to ChanInit (#14873) 2022-06-28 08:30:02 +03:00
yuyi
09630dd0bc parser: check interface name using single letter capital (#14878) 2022-06-28 08:29:23 +03:00
Emirhan Yener
6b2d3a826b gg: add draw_polygon_filled fn with rotation parameter (#14867) 2022-06-27 21:34:43 +03:00
Mehmet Ali
ae7c566232 doc: remove TODO C2V now that it's out (#14866) 2022-06-27 21:34:07 +03:00
yuyi
6be287d476 cgen: minor cleanup in ref_or_deref_arg() (#14862) 2022-06-27 21:33:35 +03:00
yuyi
044698746e parser: minor cleanup in parse_type.v (#14863) 2022-06-27 21:33:18 +03:00
Larpon
2d40ba1f49 cgen: call GC_INIT in sokol_main too, when compiling with -apk (#14869) 2022-06-27 21:24:39 +03:00
Delyan Angelov
b1a14c6cf7 tests: use a platform neutral module with C declarations (sokol.audio), instead of time in private_redeclaration_of_C_timeval.vv . 2022-06-27 19:48:46 +03:00
Delyan Angelov
94d6670e8f checker: make the type C.X is private re-declaration error more informative 2022-06-27 18:32:21 +03:00
Delyan Angelov
0ef8382824 tests: show timing info in the output of run_project_folders_test.v 2022-06-27 18:31:07 +03:00
yuyi
1af94c7edf checker: fix error for array_of_aliases.pop() (#14861) 2022-06-27 11:50:46 +03:00
WoodyAtHome
34517c340d net: support blocking sockets in TcpSocket.connect (#14849) 2022-06-27 11:01:55 +03:00
yuyi
ef7f9779a3 parser, checker: fix postfix expr check (fix #14852) (#14857) 2022-06-27 04:28:24 +03:00
yuyi
5a79a54fe4 all: fix all remaining unsafe 0 (#14856) 2022-06-26 17:04:23 +03:00
Alexander Medvednikov
cb60392302 examples: fix unsafe 0 2022-06-26 07:12:15 +03:00
Alexander Medvednikov
ca30397e7a cli: fix compilation 2022-06-26 07:08:05 +03:00
Alexander Medvednikov
e76f74fd73 checker: unsafe 0 for references (default value) 2022-06-26 06:40:40 +03:00
yuyi
546f9a544f parser: fix a typo in an error message (#14848) 2022-06-26 00:04:08 +03:00
Emirhan Yener
d42aadda0f gg: fix draw arch functions alpha color (#14850) 2022-06-26 00:03:43 +03:00
Leon Arndt
d7f962ef6e examples: remove empty comment from Tetris (#14845) 2022-06-25 05:47:44 +03:00
yuyi
ef643e106b checker: check unknown chan element type (#14843) 2022-06-25 05:19:41 +03:00
yuyi
90287f6aaa checker: check error for cast sumtype (fix #14771) (#14847) 2022-06-25 05:19:16 +03:00
CC
d336b7b877 examples: add another vweb example, showing file upload, transform, and file download (#14842) 2022-06-24 09:23:47 +03:00
Delyan Angelov
ccc3271493 docs: restore the important sentence about the mutable args that have to be marked on call 2022-06-23 21:15:21 +03:00
Emirhan Yener
e5bbb23389 examples: fix 2048 gameplay (#14838) 2022-06-23 21:07:30 +03:00
Wertzui123
c10ba6d81a os: add .cmd to the list of Windows executable suffixes (#14839) 2022-06-23 20:12:29 +03:00
Delyan Angelov
b0fe21f018 ci: fix long lines/links in docs.md 2022-06-23 20:09:20 +03:00
Alexander Medvednikov
c17200c33d doc: clear up concurrency and immutable fn args 2022-06-23 17:46:57 +03:00
Larpon
298dc77c38 ci: add pure -os android checks (#14837) 2022-06-23 11:22:55 +03:00
yuyi
e9a8f5fcc7 cgen: fix ref_struct.str() with null pointer (#14836) 2022-06-23 08:35:21 +03:00
Wertzui123
587101a1ea os: fix find_abs_path_of_executable function (on Windows) (#14835) 2022-06-23 03:36:15 +03:00
Delyan Angelov
2524207d1c tools: support c2v.exe in v translate, use os.quoted_path, cleanup errors. 2022-06-23 03:31:10 +03:00
Alexander Medvednikov
78c527b243 tutorials: improve c2v tutorial a bit 2022-06-23 02:45:14 +03:00
Alexander Medvednikov
dbc51a4579 readme: add c2v demo 2022-06-23 02:33:09 +03:00
l-m
ed8c63cc0b builtin: add a contains_only method on string (#14830) 2022-06-23 01:41:42 +03:00
Delyan Angelov
a7108ff05c docs: use the actual most recent output of c2v in the example 2022-06-23 01:39:39 +03:00
Delyan Angelov
b8d9bfec16 docs: fix C primes example in the tutorials (fixes c2v translation on linux) 2022-06-23 01:35:45 +03:00
Delyan Angelov
436081a9f5 ci: fix v check-md tutorials/ 2022-06-23 01:30:22 +03:00
Delyan Angelov
1b87a4770c tutorials: rename the folder containing spaces, to fix git checkouts on windows 2022-06-23 01:08:07 +03:00
Delyan Angelov
856270cac2 tutorials: restore the old tutorials/building_a_simple_web_blog_with_vweb/ folder. 2022-06-23 00:11:59 +03:00
Alexander Medvednikov
989c5e26f5 c2v: use https git clone 2022-06-22 22:49:29 +03:00
Alexander Medvednikov
fe673e7963 tutorials: rename vweb tutorial 2022-06-22 22:48:40 +03:00
Alexander Medvednikov
ae2183043b tutorials: c2v 2022-06-22 22:47:43 +03:00
Dialga
5cd5d551e3 v.pkgconfig: fix building standalone pkgconfig (#14825)
* Update main.v

* add test to prevent future regressions

Co-authored-by: Delyan Angelov <delian66@gmail.com>
2022-06-22 22:38:50 +03:00
Alexander Medvednikov
c9ab086029 cmd/tools: enable c2v 2022-06-22 22:10:46 +03:00
yuyi
e6c3de2f46 cgen: format cgen.init() generated c codes (#14824) 2022-06-22 21:39:15 +03:00
Larpon
3fb88500a2 os: improve Android interop (#14827) 2022-06-22 21:38:27 +03:00
yuyi
585b5145fa cgen: fix auto string method generated for []&int{len:1} (#14829) 2022-06-22 14:54:04 +03:00
Delyan Angelov
6a4ba22eae tests: flush test headers to ensure stable output with VJOBS>1 2022-06-22 12:46:32 +03:00
pancake
23d1c792c0 native: fix macho generation for macos11-amd64 (#14821) 2022-06-22 11:58:27 +03:00
Delyan Angelov
74fb473301 ci: use unique concurrency.group for native_backend_tests.yml 2022-06-22 11:23:40 +03:00
Delyan Angelov
6c060b76fd ci: fix v building inside native_backend_tests.yml 2022-06-22 11:19:00 +03:00
Delyan Angelov
48b2ab157b ci: add a separate native_backend_tests.yml, to run the native tests on all the available github actions vm environments 2022-06-22 09:11:01 +03:00
yuyi
c64c4907a2 parser: check closure var name conflict (#14823) 2022-06-22 09:04:15 +03:00
Delyan Angelov
e2e3992e0d ci: remove continue-on-error: true for most ci jobs (#14811) 2022-06-22 00:20:57 +03:00
ghosttk
8172fecb51 vweb: remove the extra '/' in scan_static_directory (#14806) 2022-06-21 15:13:09 +03:00
Larpon
9f5e442dab tools: add bump flags to vcomplete (#14813) 2022-06-21 15:11:42 +03:00
yuyi
c160ba2a8d checker: stricter mutable reference check (fix #14803) (#14805) 2022-06-21 13:23:21 +03:00
Delyan Angelov
c6f94e9cab tools: distribute vpm queries randomly between the available backend servers 2022-06-21 12:58:37 +03:00
yuyi
cab6355a38 cgen: fix array of reference sumtype index() (#14812) 2022-06-21 12:37:54 +03:00
Delyan Angelov
f08c768c8e tools: add a new readonly VPM server mirror url, to mitigate failures of the main vpm.vlang.io 2022-06-21 12:27:41 +03:00
Ulises Jeremias Cornejo Fandos
e505fcdac0 encoding.csv: update reader.v (#14807) 2022-06-21 08:31:47 +03:00
yuyi
f6f77e5264 clipboard: make clipboard.Clipboard public on windows (#14810) 2022-06-21 08:21:54 +03:00
David 'Epper' Marshall
524df8da1b math: add zpl stuff (#14543) 2022-06-21 00:17:49 +03:00
Delyan Angelov
473d26ce47 builtin: enforce linking to libgc.a with -prod on macos 2022-06-20 21:29:27 +03:00
pancake
1caff5b379 native: initial support for apple-m1 (#14795) 2022-06-20 21:25:12 +03:00
yuyi
8703e336e0 checker: cleanup in fn_decl() (#14802) 2022-06-20 17:56:02 +03:00
Delyan Angelov
1fc9e1a716 tools: build c2v in non verbose mode by default 2022-06-20 16:03:39 +03:00
Delyan Angelov
fa2e8d8459 tools: use os.system for the c2v runs to monitor the progress more easily 2022-06-20 15:50:38 +03:00
Delyan Angelov
0e4198f23b tools: fix v vet file.v for return if x { y // comment } else { z } 2022-06-20 13:29:22 +03:00
yuyi
cf1fc6f090 ast: fix array of reference sumtype appending (#14797) 2022-06-20 12:23:53 +03:00
Alexander Medvednikov
924239026c pref: disable gc for translated code 2022-06-19 20:07:45 +03:00
Alexander Medvednikov
bc60b0d1a3 builder: add -c when building object files 2022-06-19 19:57:52 +03:00
Alexander Medvednikov
d215618f4c sokol: mark pub structs 2022-06-19 19:47:47 +03:00
yuyi
de136f6baf checker: improve pub struct check (fix #14446) (#14777) 2022-06-19 17:42:22 +03:00
Delyan Angelov
37ef1ee453 tools: do show the output of c2v, when it fails 2022-06-19 17:08:21 +03:00
Delyan Angelov
7b1ade237b tools: fix the first run of v translate hw.c 2022-06-19 16:19:56 +03:00
Delyan Angelov
b9cb56572f ci: use VTEST_JUST_ESSENTIAL=1 for the -cstrict test-self task in ubuntu-clang too 2022-06-19 16:08:24 +03:00
Alexander Medvednikov
6875a173ec cmd: enable v translate, download and install c2v 2022-06-19 15:52:42 +03:00
Delyan Angelov
97be840a6d ci: use VTEST_JUST_ESSENTIAL=1 for the ubuntu -cstrict gcc task (prevent 2 hour runs) 2022-06-19 13:29:36 +03:00
lemon
e0310964d9 native: initial support for defer (#14779) 2022-06-18 23:51:31 +03:00
Alexander Medvednikov
10051e005a parser, cgen: temporary prefix ++ for translated code 2022-06-18 13:30:47 +03:00
wahur666
18dfaf6164 tools: handle fn attributes/comments more robustly, when v missdoc is run (#14774) 2022-06-18 11:02:39 +03:00
yuyi
01fdd5d07f cgen: add a minor optimisation for array.push_many (#14770) 2022-06-17 09:44:13 +03:00
Alexander Medvednikov
b89617726c pref: is_o 2022-06-16 20:51:21 +03:00
Louis Schmieder
5df3d8ac75 orm: mysql fixes (#14772) 2022-06-16 20:19:49 +03:00
Alexander Medvednikov
fb5a40d1c8 builder: handle linker errors when building .o files 2022-06-16 15:19:13 +03:00
yuyi
26714fadc5 ast, checker, cgen: improve sorting globals and consts (#14769) 2022-06-16 14:32:41 +03:00
Alexander Medvednikov
9c72b85f72 checker: temporary c2v struct init fix 2022-06-16 14:24:17 +03:00
Danilo Lekovic
df239b9208 doc: fix 'specifing' typo (#14768) 2022-06-16 11:12:58 +03:00
yuyi
f2962c34dd cgen: format module_init generated c code (#14764) 2022-06-16 11:01:17 +03:00
Delyan Angelov
205221074c tools: support v watch -k run examples/gg/rectangles.v (keep a program running) 2022-06-15 18:00:10 +03:00
yuyi
0c1708db23 cgen: minor cleanup in stmt() (#14763) 2022-06-15 17:44:00 +03:00
yuyi
5135952c9c v.util: add a retry loop for tool compilation in launch_tool() (#14760) 2022-06-15 11:59:53 +03:00
yuyi
7f38b92ca8 cgen: simplify sorting globals and consts (#14761) 2022-06-15 11:56:17 +03:00
yuyi
7c50d276c7 ast: minor cleanup in is_comptime_type() (#14759) 2022-06-14 14:21:45 +03:00
lemon
e4e858b132 transformer: fix a bug with string literal length (#14757) 2022-06-14 12:42:45 +03:00
yuyi
6d8a0ad15d ast, checker, cgen: sort consts with call expr (fix #14748) (#14755) 2022-06-14 10:50:20 +03:00
Spydr
2f1a896d18 native: integer-to-string conversion (#14758) 2022-06-14 00:35:25 +03:00
Leo Developer
67716b5b59 cgen: fix comptime if attributes for test_ functions (#14756) 2022-06-13 21:22:25 +03:00
yuyi
5efa67906c cgen: sort const array init order (fix #14748) (#14749) 2022-06-13 21:09:24 +03:00
yuyi
3535927bcd parser: correct error message for seclector_expr_assign.vv (#14747) 2022-06-12 20:29:54 +03:00
Delyan Angelov
139c34c07d gg: optimise app.gg.show_fps() (cache ctx.text_size() results, round frame to int without interpolation, center text inside the background rectangle) 2022-06-12 16:07:00 +03:00
Delyan Angelov
4682e17ac1 gg: fix v -d show_fps run examples/gg/stars.v 2022-06-12 15:17:04 +03:00
Delyan Angelov
7e06203da8 gg: support -d show_fps for all gg apps 2022-06-12 14:20:32 +03:00
Delyan Angelov
ff8e286c88 compress.gzip: support gzip.decompress(data, verify_length: false, verify_checksum: false)? 2022-06-12 11:25:01 +03:00
Spydr
5c104cf981 native: implement neg() for arm64 (#14745) 2022-06-12 09:42:39 +03:00
Spydr
8fa1e30dd2 native: int-to-string conversion detecting zeros and negative values (#14743) 2022-06-11 21:20:13 +03:00
Alexander Medvednikov
f08266ab66 doc: autofree/gc update 2022-06-11 20:44:28 +03:00
Joe Conigliaro
f3351b6a29 pref: maintain order of 'debug' in compile defines as mod cache key depends on it 2022-06-12 02:22:04 +10:00
Delyan Angelov
5cea8d30fa ci: make crun_test.v more robust by reducing the tested gap from 5x to 4x 2022-06-11 18:44:02 +03:00
yuyi
a538ab7e8c cgen: minor cleanup for sort globals and consts (#14742) 2022-06-11 18:42:22 +03:00
yuyi
cdf4ffc513 cgen: sort globals and consts definitions (#14739) 2022-06-11 17:17:49 +03:00
lemon
c7a619d16e native: support else, break, continue (#14738) 2022-06-11 11:50:19 +03:00
Dialga
da7a166708 v.pkgconfig: fix duplication in short flags to the standalone pkgconfig binary (#14740) 2022-06-11 11:06:55 +03:00
spaceface
26d051475a cgen: ensure closures are kept alive when using the GC (#14736) 2022-06-10 19:48:50 +03:00
Delyan Angelov
b27b6b2047 tools: let v gret make an easily visible diff.png image after regressions, and upload it too, to make CI failures easier to diagnose 2022-06-10 15:38:50 +03:00
yuyi
fcaf529228 parser, checker: check undefined ident in if expr using generic type name (#14734) 2022-06-10 11:57:26 +03:00
Larpon
690a8422d1 vcomplete: add -no-parallel to flag completions (#14735) 2022-06-10 11:57:12 +03:00
Delyan Angelov
f4869bcdc6 ci: add apt-get update before apt-get install in gg-regressions 2022-06-10 11:50:30 +03:00
Delyan Angelov
ea71ea3ec1 examples: speed up mandelbrot.v a little, increase iterations/details too 2022-06-09 20:10:00 +03:00
yuyi
922f003729 cgen: fix fixed array global variable (fix #14712) (#14730) 2022-06-09 16:53:19 +03:00
Larpon
be23ddc253 ci: remove VFLAGS: -gc none from vab runs (#14731) 2022-06-09 15:37:53 +03:00
yuyi
784361f153 checker: fix generic method on aliases receiver type (#14729) 2022-06-09 15:36:31 +03:00
Delyan Angelov
e1360ccf8c ci: add VTEST_JUST_ESSENTIAL=1 ./v test-self mode. Use it for alpine-docker-musl-gcc . 2022-06-09 15:26:52 +03:00
Ben
39e54a508b os: correct description of windows_volume function (#14726) 2022-06-09 10:56:58 +03:00
spaceface
4ed9780b80 all: enable -gc boehm by default (#14577) 2022-06-09 00:44:29 +03:00
yuyi
e6580fefaa ast: cleanup in generic_insts_to_concrete() (#14724) 2022-06-08 23:17:03 +03:00
Spydr
8563696476 native: added new helper functions (#14723) 2022-06-08 23:16:15 +03:00
Larpon
f58e5a94c2 gg: fire resize event before init if necessary on Android (#14725) 2022-06-08 21:43:20 +03:00
Ben
c6b1c8d07a os: add windows_volume function (#14721) 2022-06-08 21:26:24 +03:00
Mikey
5ac9b5c9f1 term.ui: don't print event data in readme example (vlang#14719) (#14720) 2022-06-08 09:36:22 +03:00
Delyan Angelov
4b3c3d9082 checker: add error for if c >= A && c <= Z { in non generic functions 2022-06-07 20:43:31 +03:00
Larpon
96a9faf2fd strings: add split_capital (#14716) 2022-06-07 18:43:06 +03:00
David Valdespino Pavon
1d462136bc net.http: cookie parsing fixes (#14420) 2022-06-07 12:52:43 +03:00
Larpon
8027919285 ci: update vab install (vlang/vab#176) (#14713) 2022-06-07 12:51:43 +03:00
Delyan Angelov
82594c0156 v.vcache: improve the output of -d trace_usecache_n 2022-06-07 12:39:30 +03:00
Delyan Angelov
a942ecf737 v.vcache: support -d trace_usecache_n too (less verbose tracing for just the initialisation of CacheManager) 2022-06-07 12:24:53 +03:00
Delyan Angelov
82d23dedf1 builtin: add flush_stdout and flush_stderr to builtin.js.v, for feature parity with builtin.c.v 2022-06-07 12:15:35 +03:00
yuyi
7780f56c31 cgen: fix cast to generic interface (#14708) 2022-06-07 08:32:25 +03:00
ChAoS_UnItY
73b59c7b16 cgen: fix none literal str() function calling (#14704) 2022-06-07 01:29:27 +03:00
yuyi
abf35270cf checker: fix json decoder with generic struct (#14700) 2022-06-06 19:25:02 +03:00
ChAoS_UnItY
ce26d5bc5c cgen: fix mutable receiver type calling mapping function causes C error (fix #14230) (#14696) 2022-06-06 18:34:04 +03:00
Delyan Angelov
778fe2cde0 ast: use [direct_array_access] for attrs []Attr lookup methods 2022-06-06 14:43:04 +03:00
Delyan Angelov
6398043094 cgen: fix missing function names in declarations on [c2v_variadic][c: xyz]fn deh_fprintf(fstream &C.FILE, fmt &i8) 2022-06-06 14:33:24 +03:00
Alexander Medvednikov
7f67981637 checker: allow literal args as references in translated code 2022-06-06 13:24:36 +03:00
yuyi
8a2236d3f8 cgen: fix generic interface with non-generic method (#14694) 2022-06-06 12:30:48 +03:00
Alexander Medvednikov
e89a6269e4 checker: do not require fn main when building an object file 2022-06-06 12:29:57 +03:00
yuyi
ce771876a3 cgen: fix nested map index check (fix #14683) (#14687) 2022-06-06 06:29:22 +03:00
ChAoS_UnItY
df80b33dc0 cgen: fix array init with it (fix #14679) (#14680) 2022-06-05 19:41:54 +03:00
Leo Developer
3a90d8ef14 compress: add a new module compress.gzip too (#14686) 2022-06-05 18:53:45 +03:00
Ikko Ashimine
7b25957a26 builtin: fix typo in array.v (#14688) 2022-06-05 18:49:40 +03:00
ChAoS_UnItY
b000728845 compress.gzip / deflate: rename gzip module into deflate module (#14682) 2022-06-05 08:48:38 +03:00
yuyi
4cf6abd99d checker: check using literal argument as reference parameter (#14674) 2022-06-05 08:44:35 +03:00
ChAoS_UnItY
f6ebbc99cd cgen: fix array type as interface (fix #14677) (#14681) 2022-06-05 05:05:48 +03:00
yuyi
5d429140a4 json: fix json decode with missing map type field (#14678) 2022-06-04 20:27:11 +03:00
Wertzui123
d71fd04c81 thirdparty/sokol: apply speaker/headset bug fix from latest upstream sokol_audio.h (#14676) 2022-06-04 20:24:07 +03:00
Delyan Angelov
3c5ae41712 examples: simplify the shebang in the v_script.vsh example 2022-06-04 20:15:39 +03:00
Delyan Angelov
3ac3375b43 cgen: fix for (int i = 0; i < 10; i++, a++) { (multiple expressions in the inc part) 2022-06-04 20:03:59 +03:00
Delyan Angelov
82eb495617 ci: on windows-msvc, skip const_fixed_array_containing_references_to_itself_test.v 2022-06-04 13:05:27 +03:00
Delyan Angelov
f2171b4148 ci: fix macos clang failures with const_fixed_array_containing_references_to_itself_test.v 2022-06-04 09:15:37 +03:00
Delyan Angelov
4cfff58fdf checker: allow for references to fixed array consts inside their initialisation const a = [ ... &a[0] ...]! 2022-06-04 09:04:12 +03:00
Alexander Medvednikov
a8461a900d vweb: use http.Cookie 2022-06-04 06:52:46 +03:00
yuyi
66572d5ead ast: cleanup is_lit() (#14672) 2022-06-03 21:02:36 +03:00
Delyan Angelov
c15d1c6e7e cgen,ci: fix cast_bool_to_int_test.v on windows-tcc 2022-06-03 20:53:10 +03:00
Delyan Angelov
6f9070e06d cgen: do not initialise externally declared globals (with -cstrict with [c_extern]). 2022-06-03 19:14:01 +03:00
Delyan Angelov
dbaecdc058 cgen: simplify int(bool_var) casts; support [c_extern] tag for global declarations 2022-06-03 18:48:08 +03:00
yuyi
daa94de93f cgen: fix autofree_variable() (fix #14576) (#14602) 2022-06-03 17:41:30 +03:00
yuyi
dcbd8d6405 cgen: fix if expr with optional method call (#14600) 2022-06-03 15:57:39 +03:00
ChAoS_UnItY
65066098d8 compress: Add gzip module & refactor compress & compress.zlib module (#14599) 2022-06-03 09:00:11 +03:00
yuyi
251716fa0e vrepl: fix error for exitasdfasdf in repl (fix #14593) (#14598) 2022-06-02 19:59:57 +03:00
Delyan Angelov
9f7656f328 ci: vfmt vlib/v/checker/check_types.v 2022-06-02 19:02:34 +03:00
Delyan Angelov
c892b3203e checker: speed up check_expected_call_arg, by only calling Table.type_to_str on errors 2022-06-02 18:58:20 +03:00
Hunam
41414b5d5f vlib: add net.http.mime (#14516) 2022-06-02 18:07:25 +03:00
Delyan Angelov
aae5b9fb95 ast.table: cache the returned values of Table.type_to_str_using_aliases/2
This results in 9% speedup of the checker stage for V itself.
2022-06-02 17:53:30 +03:00
Delyan Angelov
ed759b2ec9 ci: vfmt vlib/v/parser/parser.v 2022-06-02 15:55:13 +03:00
Delyan Angelov
031629faa1 tools: add cmd/tools/measure/scanner_speed.v and cmd/tools/measure/parser_speed.v 2022-06-02 13:50:25 +03:00
Delyan Angelov
9a0ec7f367 strings: update docs for .str() and for .free() 2022-06-02 10:41:32 +03:00
yuyi
545eaae77b ast: fix IfExpr.str() (#14595) 2022-06-02 10:28:31 +03:00
Alexander Medvednikov
8b0e843cb8 checker, cgen: c2v variadic fixes 2022-06-02 09:35:25 +03:00
yuyi
10fb16e00b parser: fix optional with multiple statements (#14592) 2022-06-02 08:23:16 +03:00
Claudio Cesar de Sá
5bf246fce6 examples: some new graphs algorithms and improving 2 others (#14556) 2022-06-02 07:11:29 +03:00
Ben
e201665e92 os: fix file_ext function (#14566) 2022-06-02 07:09:46 +03:00
Wertzui123
f971da9a93 help: add Windows to the list of supported native backends in v help build-native (#14589) 2022-06-02 07:08:46 +03:00
ChAoS_UnItY
a95cdac635 cgen: fix type not being unaliased (fix #14568) (#14591) 2022-06-02 06:21:01 +03:00
yuyi
55951e0943 checker: minor cleanup in if_expr() (#14584) 2022-06-02 06:20:09 +03:00
Hunam
d0a1608ede ci: re-enable Go2V test suite (#14588) 2022-06-02 06:19:38 +03:00
yuyi
33a2d00445 cgen: fix fixed array of aliases struct (#14583) 2022-06-01 16:56:12 +03:00
Delyan Angelov
bf70f0b436 v: add support for v crun examples/hello_world.v, use crun mode for .vsh files by default. (#14554) 2022-06-01 14:47:52 +03:00
Delyan Angelov
c91b646372 examples: document how to produce the shared library, needed for a standalone run of examples/dynamic_library_loading/use.v 2022-06-01 13:58:49 +03:00
yuyi
786045c7da parser: fix comptime if script mode (fix #6419) (#14578) 2022-06-01 13:27:27 +03:00
Delyan Angelov
5a2c271bd4 cgen: do not #include signal.h, on -os wasm32 and -d no_segfault_handler 2022-06-01 13:21:22 +03:00
Delyan Angelov
2fa64f1471 ci: skip embed_file_test.v for now 2022-06-01 12:06:02 +03:00
yuyi
fefb9643b2 checker, cgen: fix array index optional with if expr (#14575) 2022-06-01 09:18:59 +03:00
Delyan Angelov
846ddfd728 v: always embed file data of \$embed_file(file) constructs, even without -prod, unless -d embed_only_metadata is given. 2022-06-01 09:08:18 +03:00
Alexander Medvednikov
f40c30c3dc cgen: fix goto label 2022-06-01 06:34:04 +03:00
Alexander Medvednikov
c54c9b817c cgen: c2v infix fix 2022-06-01 06:14:28 +03:00
Larpon
84e375e38a toml: update readme with value_opt() usage (#14569) 2022-05-31 19:02:33 +03:00
yuyi
80cc88427b scanner: minor cleanup in scanner.v (#14565) 2022-05-31 11:52:47 +03:00
playX
db34adaec8 builtin.js: fix string.int method (#14564) 2022-05-31 11:52:11 +03:00
Delyan Angelov
dc30089c74 v.util, v.builder: fix util.module_is_builtin on macos with -usecache 2022-05-31 09:30:45 +03:00
Ben
4ffdcf8058 os: add existing_path function (#14536) 2022-05-31 06:32:12 +03:00
Delyan Angelov
928dafeb6d strconv: make f64_to_str_lnd1 public (fix building vlang/coreutils printf) 2022-05-30 22:14:22 +03:00
Delyan Angelov
fc64f09f0b crypto.md5: improve performance of md5.blockblock_generic 2022-05-30 21:56:39 +03:00
Delyan Angelov
0f3b2c2ae7 builtin: use C.fwrite (buffered) for _write_buf_to_fd (#14558) 2022-05-30 19:15:05 +03:00
Delyan Angelov
58ebc0680e builtin: fix sporadic linking failures on v -cc gcc -gc boehm examples/hello_world.v 2022-05-30 15:17:01 +03:00
yuyi
844ba2a177 checker: vfmt overload_return_type.vv (#14557) 2022-05-30 13:49:13 +03:00
Hunam
78d1b7f4ef net.http: Response.text -> Response.body (#14478) 2022-05-29 20:27:18 +03:00
yuyi
2c5febe25e scanner: fix string interpolation with inner curly braces (fix #12242) (#14553) 2022-05-29 19:28:23 +03:00
yuyi
79d861ad4f parser: fix cast or dump arguments ending with comma (#14552) 2022-05-29 09:15:55 +03:00
Delyan Angelov
63d15086e7 docs: document explicitly, that maps support if v := m[k] { too 2022-05-28 21:36:13 +03:00
Delyan Angelov
c006d5c242 cgen: add support for v -cmain SDL_main sdl_example.v 2022-05-28 21:16:48 +03:00
yuyi
c0ef6dbde8 cgen: fix cross assign in closure (#14549) 2022-05-28 20:47:54 +03:00
yuyi
7dcc19df55 ast: fix call_expr.str() with propagate_option or propagate_result (#14550) 2022-05-28 20:47:29 +03:00
Delyan Angelov
c6a6eb9a3c ci: temporary workaround for cross assignment in a closure leading to cgen error 2022-05-28 13:21:59 +03:00
yuyi
b8e8768928 parser, cgen: fix cross assign with parentheses (#14545) 2022-05-28 12:02:17 +03:00
yuyi
a46cf10e92 checker: fix declare assign literal with closure (#14544) 2022-05-28 11:50:37 +03:00
Delyan Angelov
4894f61998 toml: add pub fn (d Doc) value_opt(key string) ?Any { and some tests for toml.parse_dotted_key/1 2022-05-28 09:18:18 +03:00
yuyi
a971b9a99a parser: fix match expr case with struct init (#14538) 2022-05-27 18:51:40 +03:00
Larpon
f3e7f24ee6 tools: implement v missdoc --diff oldv newv (#14537) 2022-05-27 18:19:06 +03:00
spaceface
52a3e5e780 cgen: fix a race condition in the closure implementation (#14532) 2022-05-27 17:35:02 +03:00
Delyan Angelov
f7995c8916 checker: fix error position in fn f() int { return 1,2 } 2022-05-27 16:53:24 +03:00
Delyan Angelov
36cb552918 ci: vfmt cmd/tools/vpm.v 2022-05-27 15:22:47 +03:00
Delyan Angelov
156aa661ee tools: fix v install https://github.com/nedpals/vex.git (fix #14483) 2022-05-27 15:21:01 +03:00
Louis Schmieder
a83ac948a0 orm: document & fix pg (#14533) 2022-05-26 22:53:09 +03:00
yuyi
b97ef09b2d checker: cleanup checker.v (#14530) 2022-05-26 22:52:42 +03:00
Delyan Angelov
bb6ef8bba8 cgen: fix parallel cgen for json encoding of struct fields that have default values 2022-05-26 16:55:44 +03:00
Delyan Angelov
8c969efe6b tests: make json_test.v less noisy, to see errors easier 2022-05-26 15:27:54 +03:00
Wertzui123
1017335365 x.ttf: fix typo in README (#14528) 2022-05-26 11:17:15 +03:00
yuyi
3849cdcecc fmt: fix fn return types list ending with comma (#14529) 2022-05-26 04:20:22 +03:00
Delyan Angelov
410b57b2fa all: add support for struct field deprecation (#14527) 2022-05-26 00:44:18 +03:00
Larpon
95cc535fc7 ci: use missdoc as subcmd (#14524) 2022-05-25 19:07:07 +03:00
Larpon
9f5e999b4a tools: add v missdoc --verify mode (#14525) 2022-05-25 19:06:11 +03:00
Larpon
6c08af63ff embed_file: rename debug_embed_file_in_prod -> force_embed_file (#14523) 2022-05-25 18:26:17 +03:00
yuyi
59e57f0c62 fmt: fix fmt of Ok<[]Token>{[]} (#14522) 2022-05-25 15:17:30 +03:00
kahsa
dd8c96f6bc net.html: use -d debug_html instead of -g, prevent undesired output, while debugging user programs (#14521) 2022-05-25 11:23:56 +03:00
Delyan Angelov
31c234485a cgen: split keys and values in generated new_map_init calls into separate lines 2022-05-25 10:26:17 +03:00
yuyi
e19ac0c4a7 checker: check fn call with argument mismatch (#14519) 2022-05-25 09:00:26 +03:00
yuyi
79a75c5ac0 parser: fix fmt error for json decode (#14520) 2022-05-25 08:59:22 +03:00
yuyi
0eb3f8854d fmt: fix file with just imports (fix #14267) (#14513) 2022-05-24 20:14:08 +03:00
Ben
f431020764 os: minor clean ups on filepath.v (#14506) 2022-05-24 11:29:32 +03:00
yuyi
f35f7fe997 fmt: fix using rand.seed() when import rand and rand.seed (#14511) 2022-05-24 11:21:49 +03:00
yuyi
a5b98cb267 parser: check fn decl multi return types without parentheses (#14508) 2022-05-24 05:15:31 +03:00
yuyi
5ade39f8db cgen: fix sizeof('str') and sizeof(r'str') (#14507) 2022-05-24 05:14:38 +03:00
Delyan Angelov
953ef1f8c9 pref: add support for -dump-files - and for -dump-modules - 2022-05-23 19:51:21 +03:00
Delyan Angelov
dda49fe735 v.builder: support -dump-c-flags with -cc msvc too 2022-05-23 18:29:39 +03:00
yuyi
a3c0a9b791 checker: minor optimization in fn_call() and method_call() (#14503) 2022-05-23 08:00:57 +03:00
yuyi
4ef9e2c05a parser: fix sizeof(c'str') (fix #14499) (#14502) 2022-05-23 01:59:39 +03:00
Alexander Medvednikov
863eeca2e0 checker: vfmt checker.v 2022-05-23 00:12:37 +03:00
Daniel Däschle
5e95bdc451 checker: allow but deprecate propagating result as option (#14500) 2022-05-23 00:11:29 +03:00
yuyi
7f03b89611 checker: check method call argument type mismatch (#14496) 2022-05-22 22:16:46 +03:00
spaceface
ba859c584b builtin: add static GC support on Windows with TCC (#14497) 2022-05-22 21:25:46 +03:00
Delyan Angelov
5328dabad1 time: simplify some very commonly used t.format methods 2022-05-22 21:09:49 +03:00
spaceface
e5ff2ab455 ci: run on all branches on forks (#14498) 2022-05-22 20:19:04 +03:00
yuyi
1f3336c9d3 checker: fix map get anon fn value with mut argument (fix #14479) (#14493) 2022-05-22 16:28:53 +03:00
Alexander Medvednikov
245d28d57a checker: c2v infix fix 2022-05-22 14:53:21 +03:00
Daniel Däschle
d3ffd983c8 markused: add _result_ok (#14495) 2022-05-22 14:52:38 +03:00
Subhomoy Haldar
3647fb4def rand: move dist functions to top module and PRNG interface; minor cleanup (#14481) 2022-05-22 13:21:52 +03:00
Delyan Angelov
64a686f41f examples: speed up mandelbrot.v by using a constant size thread pool, processing smaller chunks 2022-05-22 11:12:16 +03:00
yuyi
50ab2cfd1a fmt: fix 'strings' name variable call generate auto import (fix #9713) (#14485) 2022-05-21 15:01:58 +03:00
Delyan Angelov
0ceb16f285 v.builder: use /NOLOGO, when building cached object files with msvc 2022-05-21 12:56:24 +03:00
Delyan Angelov
c0dcc80e18 cgen: support -profile - for _test.v files too 2022-05-21 10:59:01 +03:00
Delyan Angelov
a7afb2d1eb time: remove import math dependency, by implementing a simpler version of mceil 2022-05-21 02:04:17 +03:00
Ben
971c55cf30 os: add norm_path and abs_path function (#14435) 2022-05-21 01:16:29 +03:00
Daniel Däschle
efc5cab8c3 checker,cgen: allow result if guard (#14474) 2022-05-20 19:34:53 +03:00
Alexander Medvednikov
53c217fe5e cgen: do not generate _vinit() for translated .o code 2022-05-20 19:28:37 +03:00
Vincenzo Palazzo
17bba712bd checker: ban unsafe pointer/fn comparison (#14462) 2022-05-20 18:30:16 +03:00
Daniel Däschle
d81fbb1ccd ci: only run on master (#14476) 2022-05-20 18:27:35 +03:00
Delyan Angelov
dd1049f21d thirdparty: fix typo in atomic.h, cleanup comments. 2022-05-20 14:21:31 +03:00
yuyi
28b0cbddad parser: check error for script mode that define main function (fix #14467) (#14469) 2022-05-20 14:20:18 +03:00
yuyi
913164bc73 builtin: minor cleanup in string_interpolation.v (#14471) 2022-05-20 14:19:27 +03:00
yuyi
bf44572f30 fmt: fix chain calls with comments (#14470) 2022-05-20 11:47:44 +03:00
StunxFS
11bdb04d0c json: fix struct field default value support (#14304) 2022-05-20 11:22:17 +03:00
Delyan Angelov
ca00b59b3f tests: make potential failures in urllib_test.v more informative 2022-05-20 08:49:56 +03:00
David 'Epper' Marshall
120f31b4d9 math: update documentation (#14457) 2022-05-20 08:45:54 +03:00
David 'Epper' Marshall
23568f19da url: fix parse (#14456) 2022-05-20 02:58:58 +03:00
crthpl
95d24e543d checker, cgen: fix shared non-decl assignment (#14466) 2022-05-20 02:58:11 +03:00
yuyi
55e7daa2f9 cgen: simplify auto_str_methods.v (#14463) 2022-05-19 22:29:15 +03:00
crthpl
46f94e8d68 cgen: fix autostr of shared fields (#14455) 2022-05-19 17:00:27 +03:00
Daniel Däschle
a52fbc5e51 checker: forbid optional variable (#14460) 2022-05-19 16:04:44 +03:00
yuyi
3291c59ebf cgen: minor cleanup in auto_str_methods.v (#14461) 2022-05-19 14:02:07 +03:00
Delyan Angelov
634e8c3624 vfmt: keep selective imported names used for generic calls 2022-05-19 12:48:43 +03:00
yuyi
15c62bc8e8 parser: improve error messages of 'for val in array' (#14459) 2022-05-19 11:53:27 +03:00
Delyan Angelov
25812e52f0 ci: use V_CI_CSTRICT=1 consistently for every v -cstrict test-self 2022-05-19 11:52:31 +03:00
Delyan Angelov
a52590572f tests: fix the push_work_on_channel.vv output 2022-05-19 11:30:36 +03:00
Delyan Angelov
3d5617c4fa tests: re-add the disambiguated for (val in [TokenValue(+), TokenValue(-)]) { test 2022-05-19 08:31:03 +03:00
Delyan Angelov
809b1ca3b4 Revert "parser: fix 'val in array' as condition in for stmt (fix #14440) (#14451)"
This reverts commit b482c0512b.
2022-05-19 08:29:30 +03:00
yuyi
b482c0512b parser: fix 'val in array' as condition in for stmt (fix #14440) (#14451) 2022-05-18 20:38:53 +03:00
Delyan Angelov
805a7d9713 ci: skip more .vv files on specific jobs 2022-05-18 20:04:59 +03:00
yuyi
5b96f7e8fd checker: split up infix.v from checker.v (#14449) 2022-05-18 14:52:53 +03:00
yuyi
4cbfa884c5 cgen: fix another error for 'in array of sumtype' (#14448) 2022-05-18 14:39:35 +03:00
Delyan Angelov
f2447a4bd8 tests: do not use -prod for compiling .vv files in vlib/v/checker/tests/ and vlib/v/parser/tests/ 2022-05-18 13:39:57 +03:00
Delyan Angelov
2cc3b74e19 tests: cleanup compiler_errors_test.v using language features (chan), instead of raw sync.new_channel and unsafe { ch.push } calls 2022-05-18 13:39:56 +03:00
Larpon
9de0c725f6 checker: add test for empty #flag node, (fix #14291) (#14447) 2022-05-18 13:38:58 +03:00
Adam Oates
a786c58d0a os: add fn user_names() (#14424) 2022-05-18 13:37:34 +03:00
yuyi
417a6dc506 cgen: fix error for 'in array of sumtype' (#14444) 2022-05-18 08:51:31 +03:00
Larpon
8eea861c93 vcomplete: improve flag completion, add missdoc (#14415) 2022-05-18 08:50:32 +03:00
Delyan Angelov
ed17779434 math.big: fix Integer.bit_len() when there are no digits in the number 2022-05-18 08:29:08 +03:00
Delyan Angelov
ebac3bebb1 pref: pass -v after a command, to the command only, do not set verbose mode on 2022-05-18 07:03:00 +03:00
playX
a608516b82 checker: c2v fixed array fix (#14436) 2022-05-18 02:35:05 +03:00
spaceface
b5fb848508 cgen: reduce the closure memory usage (#14437) 2022-05-18 02:34:51 +03:00
Delyan Angelov
65d9c8fa6f tools: add a vet_known_failing_windows skip list to v test-cleancode 2022-05-17 20:19:37 +03:00
Delyan Angelov
dfa2d63616 ci: use VJOBS=1 for the macos v test-cleancode task too; cleanup periodic.yml 2022-05-17 19:55:28 +03:00
Delyan Angelov
4e56147223 ci: vfmt builtin_d_use_libbacktrace.c.v 2022-05-17 19:41:57 +03:00
Alexander Medvednikov
2a06290ac7 cgen: fix eq generation for translated code 2022-05-17 15:30:05 +03:00
Ned
db4b49a5ca builtin: print libbacktrace output to stderr, on panics/segfault crash (#14434) 2022-05-17 14:56:34 +03:00
Delyan Angelov
da42f0d42b ci: add an early step 'All code is formatted' to more workflows. 2022-05-17 13:14:08 +03:00
Delyan Angelov
3fc4459485 ci: ignore orm_joined_tables_select_test.v on tasks, that do not have sqlite installed 2022-05-17 12:53:07 +03:00
yuyi
020845f6c3 cgen: fix alias of array that has builtin method (#14432) 2022-05-17 12:26:26 +03:00
yuyi
d7b1e57186 v.builder: improve builder error messages (fix #14386) (#14421) 2022-05-17 12:12:20 +03:00
yuyi
60e817ff32 cgen: minor optimization in index_of_array/map() (#14429) 2022-05-17 12:08:44 +03:00
yuyi
d6aa85d059 parser: fix panic for parse invalid map type (#14431) 2022-05-17 12:05:10 +03:00
playX
7c6eaa8204 checker: allow to use [n]anyptr as [n]otherptr in check_types (c2v fix) (#14433) 2022-05-17 11:55:04 +03:00
Delyan Angelov
78ab3296c9 checker: fix orm bug, when a joined table field context replaced the original table field context 2022-05-17 11:45:17 +03:00
WoodyAtHome
02c8a6057c builtin.string: new fn (s string) is_ascii() bool (#14418) 2022-05-17 08:01:03 +03:00
Alexander Medvednikov
d10f83ce15 cgen: fix c2v struct eq 2022-05-17 03:39:48 +03:00
playX
bc397bb0e1 checker: c2v array fix (#14426) 2022-05-17 00:08:41 +03:00
Delyan Angelov
32dd801201 checker: apply fix for ui suggested by spaceface 2022-05-16 21:33:02 +03:00
Delyan Angelov
9cb8bb2968 Revert "Revert "checker: allow using methods as vars when expecting a ctx arg (#14414)""
This reverts commit e5c7fe3006.
2022-05-16 21:29:47 +03:00
yuyi
c624de8523 cgen: fix struct field array index error (#14417) 2022-05-16 19:37:39 +03:00
Delyan Angelov
e5c7fe3006 Revert "checker: allow using methods as vars when expecting a ctx arg (#14414)"
This reverts commit 36bec823c2.
2022-05-16 14:19:33 +03:00
Delyan Angelov
39874ae168 clipboard: fix v -gc boehm run x.v, where x.v does c.paste() (fix #14281) 2022-05-16 12:54:30 +03:00
yuyi
d59f4e9479 ast, cgen: fix generic method with variadic generic argument (#14404) 2022-05-16 12:26:38 +03:00
Larpon
ef6225c542 vvet: fix false positive, add test (#14403) 2022-05-16 12:24:21 +03:00
yuyi
0ab4133128 cgen: minor cleanup in struct_init() (#14405) 2022-05-16 12:22:51 +03:00
spaceface
36bec823c2 checker: allow using methods as vars when expecting a ctx arg (#14414) 2022-05-16 12:05:08 +03:00
WoodyAtHome
c2b763655d net.smtp: handle UTF-8 subjects according to RFC 1342 (#14410) 2022-05-16 11:09:36 +03:00
Delyan Angelov
1cf683d482 checker: add a suggestion for misspelled mod.const_name + a test 2022-05-16 10:29:58 +03:00
Delyan Angelov
b4c529066a tests: simplify cmd/tools/modules/testing/common.v 2022-05-16 10:29:57 +03:00
Ben
cbb24d34c9 os: fix is_abs_path function for Windows systems (#14397) 2022-05-16 09:59:37 +03:00
yuyi
7fe3ef9a6e fmt: fix fmt error of anon fn with if expr (fix #14393) (#14413) 2022-05-16 09:48:21 +03:00
Larpon
5068b8b293 ftp: document all public methods (#14408) 2022-05-16 08:52:12 +03:00
Jah-On
02e026e298 clipboard: add [heap] tag to the Clipboard structs (#14412) 2022-05-16 08:45:40 +03:00
WoodyAtHome
eeff02a8ee net.openssl: read doesn't block infinitely (#14406) 2022-05-16 08:44:34 +03:00
spaceface
c01a8a1737 checker,gen: allow using methods as function pointers (#14407) 2022-05-15 18:28:37 +03:00
Delyan Angelov
c2bc9f4960 sync: only run channel_select_test.v when VTEST_RUN_FLAKY=1 2022-05-15 12:43:04 +03:00
crthpl
e4065bd57b checker,cgen: fix if expressions in lock expression (#14384) 2022-05-15 12:31:07 +03:00
David 'Epper' Marshall
c28051020a time: fix calculate_date_from_offset (#14399) 2022-05-15 10:55:24 +03:00
Delyan Angelov
b50f7fdc71 ci: simplify ci_sanitized.yml again; use v.exe fmt -verify vlib/builtin for windows/msvc instead of v test-cleancode 2022-05-15 10:54:31 +03:00
Delyan Angelov
c70e18ea8f ci: add a skip list in compiler_test.v (for tmpl_parse_html.vv) 2022-05-15 10:23:13 +03:00
Delyan Angelov
3a09ccc80a ci: restore .github/workflows/ to its state at cee7856, when all checks were done 2022-05-15 10:23:12 +03:00
Larpon
dd6629e932 examples: fix 2048 scaling on Android (#14380) 2022-05-15 09:14:18 +03:00
David 'Epper' Marshall
8d141878ce math: cbrt fix (#14395) 2022-05-14 21:06:38 +03:00
Delyan Angelov
67963e0ff2 ci: further cleanup of ci_sanitized.yml 2022-05-14 20:34:01 +03:00
Delyan Angelov
1225a865a3 ci: simplify ci_sanitized.yml 2022-05-14 20:29:56 +03:00
yuyi
fe9f97074b cgen: fix appending struct to interface array (#14388) 2022-05-14 17:49:42 +03:00
Alexander Medvednikov
3adad32355 tmpl: fix a test 2022-05-14 17:48:50 +03:00
Alexander Medvednikov
b42c824cdb vweb: simplify @foo by removing V_TEMPLATE rule 2022-05-14 17:46:30 +03:00
Daniel Däschle
f0d46413d9 ci: require code to be formatted before everything else (minimise CI queue length) (#14396) 2022-05-14 15:38:15 +03:00
JalonSolov
b3e80a3100 examples: add missing v.mod file (#14392) 2022-05-14 14:48:42 +03:00
j. redhead
441637eeb4 checker: fix optionals in infix expression check (fix #14354) (#14390) 2022-05-14 00:54:49 +03:00
Delyan Angelov
cee7856c0f ci: add a quick v test-cleancode check, before more costlier tasks 2022-05-13 12:24:11 +03:00
Delyan Angelov
714ce4e7fc ci: fix .out regression after d407a64 2022-05-13 11:18:17 +03:00
Delyan Angelov
c1bafe7a5a ci: extract v_apps_and_modules_compile.yml 2022-05-13 11:02:24 +03:00
playX
6ec4185017 checker: allow to pass alias to array as a pointer (c2v) (#14389) 2022-05-13 10:17:28 +03:00
Daniel Däschle
d407a6449d parser: fix dollar (closes #14292) (#14378) 2022-05-13 08:30:10 +03:00
Delyan Angelov
ed12a5c84c math.big: reduce memory usage of Integer.str() (free intermediary Integers), optimise some operations using [direct_array_access] (#14353) 2022-05-13 08:21:34 +03:00
yuyi
3c95504a35 checker, cgen: fix generic fn with array and fixed array arguments (#14385) 2022-05-13 06:57:48 +03:00
Daniel Däschle
d679146a80 fmt: remove space in front of ? and ! (#14366) 2022-05-13 06:56:21 +03:00
Delyan Angelov
df029da942 Revert "ci: run code-formatting job before everything else (try 2) (#14379)"
This reverts commit 0972e67f72.
2022-05-12 23:29:37 +03:00
Daniel Däschle
0972e67f72 ci: run code-formatting job before everything else (try 2) (#14379) 2022-05-12 21:58:11 +03:00
Delyan Angelov
8ef9dc6247 ci: run v fmt -w vlib/v/checker/fn.v (fix CI regression after 4952967) 2022-05-12 21:24:12 +03:00
Delyan Angelov
668d1b04d2 parser: make script mode errors more informative, when a top level declaration is encountered, after script mode had already started 2022-05-12 21:14:00 +03:00
Hunam
20139ad756 checker: fix typo (#14368) 2022-05-12 12:23:32 +03:00
playX
4952967366 checker: alias C2V fix (#14377) 2022-05-12 12:19:31 +03:00
yuyi
f48f7014f0 checker: check error for generic sumtype types (#14374) 2022-05-12 11:57:57 +03:00
penguindark
e93a8766e5 regex: fix #14370, last IST not managed in advance tests (#14372) 2022-05-12 11:49:57 +03:00
Delyan Angelov
b7ca4c1668 checker: fix a compiler panic on fntest()?(&int,&int){return test()?} 2022-05-12 11:36:32 +03:00
yuyi
8830af5c89 rand: minor cleanup in choose() (#14376) 2022-05-12 11:20:38 +03:00
yuyi
5bc4fea9e0 checker: check error for cast function to string (#14375) 2022-05-12 10:04:38 +03:00
CC
901b8f0c24 builtin: add a map.clear() method (#14373) 2022-05-12 09:43:01 +03:00
spaceface
49382f1f43 gen: make the closure implementation more performant (#14352) 2022-05-12 00:05:14 +03:00
Emily Hudson
c19b037880 net: select with deadlines (#14369) 2022-05-12 00:03:48 +03:00
yuyi
cd4fa041ff checker: check generic sumtype declare error (#14367) 2022-05-11 17:39:58 +03:00
Larpon
34a252ef84 os: add raw_execute on Windows (#14363) 2022-05-11 16:56:03 +03:00
David 'Epper' Marshall
26b81d68b5 time: update doc comments (#14359) 2022-05-11 16:55:19 +03:00
Larpon
0ec1c8d9f0 szip: expose zip_folder (#14356) 2022-05-11 16:48:41 +03:00
yuyi
3afc7c4c6d parser: check error for generic struct parameter (#14362) 2022-05-11 13:24:54 +03:00
Delyan Angelov
cf536b848b Revert "strings: reduce time spent in Builder.writeln (very frequently called)"
This reverts commit b53b1cc7cb.
2022-05-11 09:19:37 +03:00
yuyi
8f765ed5f1 checker: minor cleanup and speedups in fn_call() (#14343) 2022-05-10 16:41:47 +03:00
yuyi
5697d4375b cgen: fix error for printing aliases of multi fixed array (#14348) 2022-05-10 14:03:18 +03:00
yuyi
606d8cfaca checker: check error for returning aliases of fixed array (#14349) 2022-05-10 14:01:55 +03:00
Isaiah
9e09b709e3 net.http: fix crash on Windows when using Boehm GC (#14351) 2022-05-10 14:00:55 +03:00
yuyi
940c78bdfd checker: minor cleanup in method_call() (#14342) 2022-05-09 18:01:44 +03:00
Subhomoy Haldar
79f8a3c796 rand: update README.md (#14341)
* update README for rand module

* use concrete values

* make sure code works
2022-05-09 17:59:20 +03:00
StunxFS
d24dce8eb3 parser,checker: support $compile_error('message') and $compile_warn('message') (#14320) 2022-05-09 08:18:26 +03:00
Dialga
4400f9891e szip: fix extracting dot folders (#13387) 2022-05-09 07:45:36 +03:00
yuyi
8519996201 checker: fix error for match sumtype that referenced before (#14338) 2022-05-09 07:32:51 +03:00
Merlin Diavova
106487d62f pg: resolve PG string datetime values to V time.Time ones (#14336)
Co-authored-by: Merlin Diavova <md@merlindiaova.org>
2022-05-08 15:37:46 +03:00
David 'Epper' Marshall
650fb493bd regex: add split (#14329) 2022-05-08 15:21:39 +03:00
Delyan Angelov
084f2867b6 time: let time.parse_rfc3339('2015-01-06T15:47:32.080254511Z') succeed (dockerd timestamps, Go's RFC3339Nano). 2022-05-08 14:54:57 +03:00
WoodyAtHome
a0a3499bdc net.smtp: correct date in smtp body (#14326) 2022-05-08 09:15:45 +03:00
Alexander Medvednikov
0526499d5f tools: hide tcc warning on macos for now 2022-05-08 08:01:55 +03:00
Merlin Diavova
f8747d05dc pg: add type 18 for pg boolean data type (#14335) 2022-05-08 07:17:43 +03:00
StunxFS
d5e70552eb checker: check error for json.decode (fix #6732) (#14305) 2022-05-08 07:17:11 +03:00
David 'Epper' Marshall
aef95721a4 strings: builder: add clear (#14328) 2022-05-08 07:15:42 +03:00
yuyi
b04d46770b ast, checker, cgen: fix error for generic method with generic fn type argument (fix #14239) (#14333) 2022-05-07 20:22:20 +03:00
yuyi
724e7f037a cgen: fix error for if cond with optional expr (#14334) 2022-05-07 20:20:00 +03:00
David 'Epper' Marshall
a91226c376 docs: cleanup (#14327) 2022-05-07 20:18:42 +03:00
Delyan Angelov
b53b1cc7cb strings: reduce time spent in Builder.writeln (very frequently called) 2022-05-07 12:55:41 +03:00
Delyan Angelov
7ecd65221e v.util: support -d trace_cached_read_source_file 2022-05-07 12:55:41 +03:00
Delyan Angelov
56cf0b0a2e builtin: inline manually isnil calls in array.push_many (very frequently called) 2022-05-07 12:55:40 +03:00
Delyan Angelov
7f974a275a docs: fix teh typo 2022-05-07 12:55:40 +03:00
Delyan Angelov
f956acd2f6 ci: restore the v -autofree . step for gitly (gitly now has a workaround) 2022-05-07 12:55:40 +03:00
Delyan Angelov
9e8e364493 ci: comment out the go2v testing step for now 2022-05-07 12:55:39 +03:00
Alexander Medvednikov
ca42ace367 Revert "checker: remove more unnecessary void errors"
This reverts commit 89c1e7f980.
2022-05-07 11:03:12 +03:00
Alexander Medvednikov
35cfa0da7c doc: closures work on arm64 too 2022-05-07 11:02:53 +03:00
playX
6a6c005dc0 checker: c2v fixes (#14332) 2022-05-07 09:50:41 +03:00
Alexander Medvednikov
9fb8de14dd doc: closures now work on Windows 2022-05-07 09:49:33 +03:00
Alexander Medvednikov
89c1e7f980 checker: remove more unnecessary void errors 2022-05-07 09:09:18 +03:00
yuyi
70184ad1f8 scanner: minor simplification in scanner.v (#14331) 2022-05-07 08:30:15 +03:00
Alexander Medvednikov
14f06ead1b cgen: fix c2v consts; enum_decl() 2022-05-07 00:58:37 +03:00
yuyi
621574c12a checker: fix error for generic method on nested struct (#14322) 2022-05-07 00:51:04 +03:00
Hunam
0699f324b5 builtin: add map.values() (#14301) 2022-05-06 20:42:01 +03:00
Lathanao
ce99a306c0 net.http: make parse_form return POST requests with json data as a map with a json key, containing the json payload (#14289) 2022-05-06 20:23:36 +03:00
StunxFS
87de6df0e6 docs: update keyword list (#14319) 2022-05-06 20:17:45 +03:00
Ekopalypse
2027a1969b v.builder: harmonise the default settings of the different Windows compilers (#14314) 2022-05-06 19:28:13 +03:00
Daniel Däschle
76cdf75299 builtin,cgen: rename Option to _option (#14317) 2022-05-06 19:25:54 +03:00
yuyi
45fe87c9e3 checker: minor cleanup in fn_call() (#14307) 2022-05-05 21:15:54 +03:00
yuyi
3091f31019 checker: check for optional argument in dump() (#14316) 2022-05-05 21:15:22 +03:00
Claudio Cesar de Sá
634796ae42 examples: 2 new examples for graph algorithms (topological sorting) (#14303) 2022-05-05 18:08:08 +03:00
Andréas Livet
9fde5b067b docs: add missing function names in the builtin example doc comments (#14318) 2022-05-05 17:22:25 +03:00
Daniel Däschle
89fe82b732 checker: fix returning error on reference results (#14313) 2022-05-05 17:02:49 +03:00
yuyi
b6058bfd6e parser, checker: fix generic method on nested struct (fix #14089) (#14310) 2022-05-05 11:24:20 +03:00
playX
8afdb1c3ef checker: c2v: allow passing fixed array as pointer to functions; bool <-> int (#14309) 2022-05-05 11:23:57 +03:00
StunxFS
7499506cf8 .gitignore: minor cleanup (#14279) 2022-05-05 10:17:24 +03:00
Delyan Angelov
785e9af8f1 ci: comment out the v -autofree . step for gitly temporarily 2022-05-05 09:20:08 +03:00
Delyan Angelov
7170a09382 vfmt: fix stackoverflow on long nested infix expressions 2022-05-05 07:41:43 +03:00
Delyan Angelov
01c1892995 tools: fix building vdoctor.v with v build-tools 2022-05-04 23:30:44 +03:00
Delyan Angelov
a6b3e5d6a5 ci: wrap the too long line in README.md that failed ./v check-md -hide-warnings . 2022-05-04 21:19:57 +03:00
Ned
76a7354506 builtin: add libbacktrace as option for generating stack traces (#14277) 2022-05-04 21:17:05 +03:00
yuyi
4242e7610f checker: add comptime_selector() (#14286) 2022-05-04 19:25:58 +03:00
yuyi
e2aa5c9b3f parser: make peek_token_after_var_list() private (#14288) 2022-05-04 19:25:45 +03:00
Ikko Ashimine
223b96a59a builtin: fix typo in array_bare.v (#14299) 2022-05-04 19:25:17 +03:00
Delyan Angelov
1a4d9017e2 builtin: improve support for large arrays ([]int{len: 1_000_000_000} now works), fix an arr.repeat() bug (#14294) 2022-05-04 18:42:06 +03:00
Alexander Medvednikov
af8be14639 readme: minor github markdown fix 2022-05-04 18:06:41 +03:00
yuyi
ac90a2b53d checker: check error for fn call argument mismatch (fix #14280) (#14283) 2022-05-04 12:13:22 +03:00
playX
3bd6455178 checker: allow rune->any int and vice versa when translated (#14285) 2022-05-04 12:08:34 +03:00
Alexander Medvednikov
3d4b8dffdf checker: temporary c2v const fix 2022-05-04 08:28:27 +03:00
yuyi
f321422964 checker, cgen: check comptime selector that has no field name (#14282) 2022-05-04 07:06:52 +03:00
Alexander Medvednikov
1e9156fd71 checker: c2v rune comparison fix 2022-05-04 06:49:45 +03:00
yuyi
3732db2bcc cgen: cleanup in gen_array_contains_methods() (#14274) 2022-05-03 20:46:07 +03:00
playX
146051b231 checker: allow fixed array to pointer and vice versa when translated (#14275) 2022-05-03 20:44:45 +03:00
Delyan Angelov
04a77c731e tests: add // vtest flaky: true to atomic_test.v 2022-05-03 20:42:12 +03:00
yuyi
63eacede95 checker: check argument mismatch of array.filter/all/any() (#14273) 2022-05-03 16:56:18 +03:00
Hunam
6da300428e doc: add JS backend mention (#14265) 2022-05-03 12:51:12 +03:00
yuyi
276bd8060c cgen: fix error for fixed array in operate (#14269) 2022-05-03 12:45:04 +03:00
Delyan Angelov
0e5c1cee48 builtin: improve musl/Alpine support (define weak backtrace/backtrace_symbols/backtrace_symbols_fd symbols) (#14250) 2022-05-03 09:17:53 +03:00
Delyan Angelov
4da2908d63 vdoc: fix panic on empty // comment on v doc -f html file.v; turn expected code block after empty example to a warning 2022-05-03 00:02:12 +03:00
StunxFS
cf92224248 cleanup: delete x.v in project root folder (#14260) 2022-05-02 22:58:14 +03:00
Delyan Angelov
ab1c265679 builtin: add missing panic_result_not_set/1 callback function. 2022-05-02 22:40:26 +03:00
spaceface
db185598d2 checker: refactor comptime_if_branch (#14259) 2022-05-02 22:24:20 +03:00
yuyi
990afe37e1 checker: fix a bug in generics array init (#14258) 2022-05-02 16:18:33 +03:00
yuyi
d72a25098a parser: minor cleanup in interface_decl() (#14257) 2022-05-02 16:17:46 +03:00
yuyi
25c1b174ca checker: fix generic fn infering fn type argument (fix #14243) (#14256) 2022-05-02 16:17:27 +03:00
yuyi
b9cf2db6a8 parser: fix inline array's element access (#14253) 2022-05-02 16:16:32 +03:00
playX
afbe6bf3a2 cgen: fix const decl gen when translated (#14255) 2022-05-02 15:01:59 +03:00
Isaiah
a4fd349cf1 builder: allow -compress to work on windows too, when upx is installed (#14252)
Allow `-compress` flag on Windows if upx is installed. If upx not installed, same behavior as on linux/mac
2022-05-02 14:28:31 +03:00
yuyi
968d2b4654 cgen: fix fixed array init with it (#14251) 2022-05-02 02:00:45 +03:00
spaceface
332e821518 checker, gen: add support for a [minify] struct attribute (#14247) 2022-05-02 01:59:17 +03:00
Delyan Angelov
aed2d0caf2 make files: add a make check target, that runs v test-all locally 2022-05-01 13:38:30 +03:00
David 'Epper' Marshall
91c1157810 time: relative update (#14240) 2022-05-01 10:47:05 +03:00
Daniel Däschle
ec92d467d1 cgen: fix unsafe return error (#14233) 2022-04-30 17:31:28 +03:00
playX
0b54196962 checker: allow pointer index for translated code (#14231) 2022-04-30 17:30:55 +03:00
Daniel Däschle
9f8a34a528 all: rename result to _result (#14232) 2022-04-30 17:10:30 +03:00
Delyan Angelov
63d413f93c tools: support v missdoc . instead of v run cmd/tools/missdoc.v . 2022-04-30 16:12:39 +03:00
Delyan Angelov
c0b37409d2 tools: support a v vet -p file.v option that will warn about private functions with missing documentation 2022-04-30 16:09:30 +03:00
Delyan Angelov
8da42bfc85 tests: fix ./v -W build-tools CI failure 2022-04-30 13:49:36 +03:00
Delyan Angelov
5277ce7dce tests: support for marking _test.v files with // vtest flaky: true, to reduce false positives from the CI 2022-04-30 13:30:02 +03:00
David 'Epper' Marshall
a2338dbb7c docs: document more builtin functions/methods (#14229) 2022-04-30 12:31:23 +03:00
Delyan Angelov
dcdfdf4dd8 tools: make v up more informative on failure 2022-04-30 10:11:02 +03:00
spaceface
dab649ec8a cgen: rewrite the closure implementation (#14223) 2022-04-30 09:32:46 +03:00
Alexander Medvednikov
ce31a01a70 checker: allow voidptr arithmetic in translated code 2022-04-30 05:52:37 +03:00
yuyi
cd30b6ea82 parser: make sure interface field names use uppercase letters (#14228) 2022-04-30 05:29:33 +03:00
Daniel Däschle
08fd0ce0de all: basic implementation of result type (#14140) 2022-04-30 01:59:14 +03:00
StunxFS
db185e6580 checker: check for reserved type names in for in (fix #14072) (#14212) 2022-04-30 01:25:29 +03:00
Benjamin Thomas
48eb40cd2c doc: suggest a basic auto-reload setup (#14216) 2022-04-29 20:57:04 +03:00
David 'Epper' Marshall
881d0c04f1 time: add custom formatter (#14202) 2022-04-29 15:57:08 +03:00
yuyi
ec865cfb37 parser: check interface methods name (fix #14217) (#14218) 2022-04-29 15:48:03 +03:00
yuyi
317acfda97 checker: check struct field name using uppercase letters (#14220) 2022-04-29 14:57:14 +03:00
Wertzui123
872f739396 builtin: ignore C++ 0xE06D7363 exception errors on windows (#14225) 2022-04-29 14:55:29 +03:00
StunxFS
995485c649 builtin: add string.len_utf8() method (#14208) 2022-04-29 10:23:57 +03:00
StunxFS
8b798acadd cgen: fix use of C reserved words inside defer statement (fix #14101) (#14211) 2022-04-29 08:04:59 +03:00
Alexander Medvednikov
77645fcf35 builtin: define atoi & ftell 2022-04-29 04:31:51 +03:00
spaceface
14309594fe ast: add a type_size() method (#14213) 2022-04-28 23:35:10 +03:00
David 'Epper' Marshall
5a42350a78 docs: add a v fmt -w . step in the contributing guide (#14210) 2022-04-28 23:31:22 +03:00
StunxFS
e24482a143 transformer: minor optimization for 'string literal'.len (#14207) 2022-04-28 22:35:16 +03:00
playX
e56385d57d checker: disable op overloading on structures for translated code (#14209) 2022-04-28 20:46:46 +03:00
yuyi
7aca67fb60 ast, parser: fix complex map init (#14206) 2022-04-28 17:37:19 +03:00
yuyi
dd94ab890a cgen: fix go anon fn call with ref argument (fix #14192) (#14197) 2022-04-28 14:43:20 +03:00
yuyi
c802688690 ast: fix error for complex map operating (#14204) 2022-04-28 13:20:56 +03:00
Atom
a225b25117 arrays: rephrase doc string (#14205) 2022-04-28 13:17:53 +03:00
Delyan Angelov
4538efd8f4 eval: small cleanup in the handling of $if platform { 2022-04-28 13:15:09 +03:00
Delyan Angelov
e0ed8f8278 eval: make the interpreter backtrace more efficient and informative. 2022-04-28 12:31:30 +03:00
Delyan Angelov
f72297c331 eval: add support for C.read/3, C.malloc/1, $if openbsd { 2022-04-28 11:30:36 +03:00
Delyan Angelov
be04ec0620 pref: add support for -thread-stack-size 4194304 (default set to 8MB) (#14168) 2022-04-28 08:46:33 +03:00
yuyi
7dd5d9ee61 checker: fix error for array of sumtype appending literal value (#14200) 2022-04-28 08:44:30 +03:00
yuyi
09f8b6a380 checker: check error in for_c_stmt with optional call (#14190) 2022-04-28 08:43:16 +03:00
tzSharing
eb03fad934 gg: improve some loops in draw_rounded_rect* methods (#14195) 2022-04-27 22:57:48 +03:00
Delyan Angelov
f53b9b4f12 ci: fix tcc compilation of atomic_test.v 2022-04-27 22:50:18 +03:00
Alexander Medvednikov
7dbfa86f25 all: atomic int fixes 2022-04-27 18:31:21 +03:00
yuyi
82ac39eca6 math: fix error for math.abs(0.0)/math.abs(0) (related #14165) (#14191) 2022-04-27 13:23:37 +03:00
yuyi
752e105f25 cgen: fix error for generic sumtype casting to typenode (#14188) 2022-04-27 11:32:43 +03:00
tzSharing
85f616877f gg: fix gg.draw_rounded_rect_empty() graphical abnormalities and some optimizations (#14186) 2022-04-27 11:22:57 +03:00
playX
b76095f28a checker: allow + - * on pointers for translated code (#14183) 2022-04-26 21:00:44 +03:00
R cqls
c26b7666c7 gg: some stuff required to have svg and png screenshots working on v ui (#14180) 2022-04-26 20:59:36 +03:00
yuyi
be513b4c27 cgen: split up array_init() (#14178) 2022-04-26 20:58:47 +03:00
Larpon
1c48a8d760 strconv: add missing doc strings (#14164) 2022-04-26 18:09:36 +03:00
yuyi
660201c188 cgen: fix error for cast to empty interface (fix #14162) (#14176) 2022-04-26 13:26:48 +03:00
Brian Callahan
b9a0e2d285 sokol: support compilation on OpenBSD (#14169) 2022-04-26 13:14:00 +03:00
yuyi
38afd74d26 ast, checker, cgen: fix error for multi-return in or expr (fix #14167) (#14172) 2022-04-26 12:17:05 +03:00
playX
95880dfe5c checker: allow indexing through alias to int (#14177) 2022-04-26 12:15:35 +03:00
playX
dce2173ac9 checker: c2v fixes (#14161) 2022-04-26 01:34:26 +03:00
Alexander Medvednikov
501b293e84 checker: remove already handled "undefined" errors 2022-04-25 16:53:34 +03:00
Larpon
d799abd139 regex: rephrase doc string (#14159) 2022-04-25 16:03:13 +03:00
yuyi
e42dc8e228 checker: fix error for match aliases (#14157) 2022-04-25 14:42:43 +03:00
yuyi
f89c81087b checker: check error for array.index() argument (#14147) 2022-04-25 14:42:31 +03:00
yuyi
aeba110d01 cgen: fix error for printing multi fixed array (#14141) 2022-04-25 14:42:05 +03:00
Larpon
283d181047 cli: add missing doc strings (#14158) 2022-04-25 14:41:46 +03:00
yuyi
88f22b4367 cgen: fix error for anon fn decl inside ternary (#14150) 2022-04-25 12:36:03 +03:00
Delyan Angelov
60e205a193 tests: add ability to check the output of commands for .starts_with, .ends_with and .contains strings, in v test-all 2022-04-25 12:20:38 +03:00
Delyan Angelov
d35d67c2bd eval: enable v interpret examples/hanoi.v 2022-04-25 12:20:37 +03:00
Nick Treleaven
d8a5df9044 checker: error if smaller signed == unsigned (#14078) 2022-04-25 12:09:25 +03:00
Delyan Angelov
147e6e669f cgen: fix pushing to an array of string pointers (fix #14156) 2022-04-25 11:26:24 +03:00
yuyi
922cee9162 parser, checker, cgen: fix error for fn call using anon fn call argument (#14155) 2022-04-25 11:26:14 +03:00
Delyan Angelov
1291b621f6 ci: bump test retries for go_anon_fn_variable_call_test.v to 3 2022-04-25 10:32:41 +03:00
fleur
ddbe812f1b cgen: add callconv support for fns from ptr (#14151) 2022-04-25 08:51:03 +03:00
Haren S
11ee2b6409 builder: improve macOS 10.5 and PPC support (#14152) 2022-04-25 08:17:00 +03:00
stackotter
563469ed9f vfmt: fix array_init line wrapping (#14154) 2022-04-25 08:11:44 +03:00
yuyi
c819f0f86f checker, cgen: fix printing in 'for v in a' (#14146) 2022-04-24 13:30:13 +03:00
Alexander Medvednikov
9355048b6c tmpl: minor fixes and optimizations 2022-04-23 16:01:44 +03:00
Delyan Angelov
3388caa6c5 ci: bump vtest retry to 6 for channel_select_test.v (fails sporadically in the windows-gcc job) 2022-04-23 15:36:19 +03:00
Delyan Angelov
365e7d6b34 vfmt: ignore parser warnings, cleanup code 2022-04-23 11:10:12 +03:00
yuyi
d934472b17 checker: simplify checking array.contains() argument (#14133) 2022-04-22 22:34:13 +03:00
yuyi
b86320a669 parser: minor cleanup in stmt() (#14136) 2022-04-22 22:33:13 +03:00
Claudio Cesar de Sá
a2db44bc38 examples: add 2 more graph search examples (DFS and BFS), move them into examples/graphs (#14131) 2022-04-22 12:01:29 +03:00
yuyi
5dce091379 checker, cgen: fix generic empty interface to multi struct (#14132) 2022-04-22 11:02:51 +03:00
Alexander Medvednikov
9b565bf765 cgen: fix enum switch bug in translated code 2022-04-22 02:31:32 +03:00
tzSharing
03d21a727e gg: fix gg.draw_rounded_rect_filled() graphical abnormalities (#14128) 2022-04-22 00:16:10 +03:00
Larpon
506259adb6 os: add behavior info to is_dir_empty documentation (#14110) 2022-04-21 18:21:00 +03:00
yuyi
26b0e7fd34 fmt: remove extra parentheses (#14125) 2022-04-21 18:20:32 +03:00
Delyan Angelov
2080557f50 ast: allow a := match x { 101 { ... for {...} ... y } 2022-04-21 13:31:06 +03:00
yuyi
8a18f9175a cgen: fix error for if expr with nested match expr (#14122) 2022-04-21 13:02:31 +03:00
yuyi
448938be0d parser: fix generic anon fn decl with type only argument (#14124) 2022-04-21 12:53:13 +03:00
yuyi
99eb9fdaab checker: fix error for fn with array of aliases argument (#14123) 2022-04-21 12:52:09 +03:00
yuyi
f13583b04a checker: check array builtin method's arguments (#14119) 2022-04-21 12:51:04 +03:00
yuyi
8013bd43b0 checker: check map builtin method's arguments (#14120) 2022-04-21 12:49:46 +03:00
Delyan Angelov
5e8c4a3aff ci: enable again the v install ui task 2022-04-21 11:21:59 +03:00
StunxFS
2a0b372d0d tools: minor cleanup in fast.v (#14117) 2022-04-21 10:46:35 +03:00
ChAoS_UnItY
c5824c36f2 checker, cgen: allow static (fixed) arrays in in operator (#14121) 2022-04-21 10:32:29 +03:00
Delyan Angelov
c789ea5a15 ci: temporarily use git clone https://github.com/vlang/xyz ~/.vmodules/xyz instead of v install xyz 2022-04-21 09:20:15 +03:00
sunnylcw
4491b535ec doc: add link to V's standard library documentation at the start (#14114) 2022-04-21 00:26:20 +03:00
Delyan Angelov
31b28af179 bootstrap: remove -I ./thirdparty/stdatomic/nix from make files (#14111) 2022-04-21 00:12:50 +03:00
lemon
960225f7a7 builtin: fix -cc gcc -gc boehm on linux and macos (#14115) 2022-04-21 00:12:17 +03:00
Nick Treleaven
1533b77404 builtin: remove unnecessary casts for defunct small unsigned warning (#14108) 2022-04-20 21:47:09 +03:00
yuyi
0260c2a552 checker: minor cleanup in assign_stmt() (#14107) 2022-04-20 21:03:41 +03:00
Hunam
0374f021c5 os: small cleanup of function description (#14112) 2022-04-20 20:58:41 +03:00
mjh
1546645f63 datatypes: fix bst child access, when .root is 0 (#14080) 2022-04-20 16:49:18 +03:00
Larpon
a1342e85c3 os: add info about overwritten content to write_file (#14109) 2022-04-20 15:29:58 +03:00
yuyi
52ea0b8cc3 ast: minor cleanup of types.v (#14103) 2022-04-20 14:24:13 +03:00
yuyi
ce4c2afc9c checker, cgen: use 'stmts.last()' instead of 'stmts[stmts.len - 1]' (#14105) 2022-04-20 14:23:32 +03:00
yuyi
44ba19716b checker: fix error for fn with multi return (#14095) 2022-04-20 13:09:40 +03:00
yuyi
0c3b69eaef checker: fix error for assign array of aliases (#14096) 2022-04-20 13:08:47 +03:00
Alexander Medvednikov
364656b312 builtin: define C.abs() 2022-04-20 13:03:30 +03:00
Isaiah
0887b59254 vpm: fix get_all_modules() (#14097) 2022-04-20 12:15:30 +03:00
yuyi
8cc79e4299 checker: check error for arguments of array.contains() (#14102) 2022-04-20 11:00:59 +03:00
playX
711e90cf99 v.util: add math to builtin_module_names (temporary fix for C2V) (#14100) 2022-04-20 10:57:55 +03:00
playX
f6a0c26a85 checker: c2v fixes (#14091) 2022-04-20 01:09:34 +03:00
Delyan Angelov
9646e4b9d8 sync: use #insert for atomic.h, so that bootstrapping can be simplified 2022-04-19 20:06:20 +03:00
Delyan Angelov
006df58451 checker, cgen: add support for #insert, to simplify bootstrapping V 2022-04-19 19:37:04 +03:00
JalonSolov
daf5d32327 checker: fix error message when number of generic parameters is incorrect (#14090) 2022-04-19 18:34:23 +03:00
yuyi
a318a2e09e examples: fix optional in string interpolation and format error (#14079) 2022-04-19 13:29:53 +03:00
yuyi
e16ce3af88 token: minor cleanup of token.v (#14083) 2022-04-19 13:28:27 +03:00
yuyi
6164654d11 checker: check fn return type mismatch (#14081) 2022-04-19 13:04:41 +03:00
Nick Treleaven
4400efeb9f checker: Revert part of small_unsigned == signed (#13967) (#14075)
`gcc -W` doesn't error for e.g. u16 == i32, only for u32 == i16.
Any u16 value can fit in an i32.
2022-04-18 21:30:09 +03:00
yuyi
7ef64bde50 checker: check error for fn decl with optional arguments (#14076) 2022-04-18 21:22:31 +03:00
yuyi
d0a11f50ca cgen: minor cleanup of infix_expr.v (#14070) 2022-04-18 15:05:19 +03:00
Delyan Angelov
379b638b57 ci: update windows-install-sqlite.bat to latest sqlite 2022-04-18 14:25:57 +03:00
yuyi
fe371845da ast, checker, cgen: fix aggregations type check (#14066) 2022-04-18 12:38:08 +03:00
spaceface
775c4c34b5 builtin: compile the gc statically by default (#14063) 2022-04-18 10:50:21 +03:00
Ikko Ashimine
56a3539ea9 io: fix typo in readerwriter.v (#14060)
seperate -> separate
2022-04-17 17:40:14 +03:00
yuyi
17c34b09a6 checker, cgen: minor cleanup of last expr stmt expression (#14057) 2022-04-17 14:08:43 +03:00
yuyi
cb44f5981e checker, cgen: fix error for if expr with generic sumtype (#14056) 2022-04-17 08:19:44 +03:00
Vincenzo Palazzo
4f14f7714f checker: ensure that the variant SubType exists (#14053)
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-04-16 19:29:10 +03:00
Vincenzo Palazzo
48486e1afb ci: reformatted tools/vcreate.v (#14054)
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-04-16 19:09:08 +03:00
Cameron Katri
1fc54a1e5b vcreate: Allow custom default license (#14046) 2022-04-16 17:43:25 +03:00
Delyan Angelov
8a57f7ed2d v.util: always compile vfmt with -d vfmt to enable more efficient parsing 2022-04-16 14:05:55 +03:00
Julien de Carufel
16ead4e63c cgen: fix infix generics bug (#14048) 2022-04-16 13:23:19 +03:00
Alexander Medvednikov
43931a8e77 doc: byte => u8 2022-04-16 13:02:56 +03:00
Delyan Angelov
5b7e538119 v.pref: show the VCROSS_COMPILER_NAME notice only when the output is not a .c file 2022-04-16 10:46:03 +03:00
Delyan Angelov
4a71b27c52 ci: add test_byte_vs_u8 to int_test.v 2022-04-15 21:42:07 +03:00
Delyan Angelov
d75c408868 ci: fix typeof_simple_types_test.v 2022-04-15 21:22:32 +03:00
Delyan Angelov
82c5621621 ci: fix typeof_simple_types_test.v 2022-04-15 21:21:44 +03:00
Delyan Angelov
675f8b6300 ci: fix generic_fn_infer_struct_test.v 2022-04-15 21:21:12 +03:00
Delyan Angelov
ad231cec2f ci: fix code_test.v 2022-04-15 21:20:03 +03:00
Delyan Angelov
87a373d82c ci: fix coutput_test.v 2022-04-15 21:18:55 +03:00
Delyan Angelov
c7aedb8e8d ci: fix fmt_test.v 2022-04-15 21:16:31 +03:00
Delyan Angelov
375361b787 ci: fix ./v check-md -hide-warnings . 2022-04-15 21:08:09 +03:00
Delyan Angelov
840f474fb5 ci: fix ./v -progress test-cleancode 2022-04-15 21:04:10 +03:00
Delyan Angelov
e802e0b9cb ci: fix more test-all failures 2022-04-15 21:02:03 +03:00
Delyan Angelov
bb2a324d61 ci: more gen.js fixes 2022-04-15 20:51:04 +03:00
Delyan Angelov
868d3e1008 ci: fix failing tests for mysql, crypto.rc4, strings 2022-04-15 20:51:04 +03:00
Alexander Medvednikov
c03fe020bf parser: do not allow [x]byte{} 2022-04-15 20:40:37 +03:00
Delyan Angelov
6f5a513d8b ci: fix v build-examples 2022-04-15 20:31:10 +03:00
Delyan Angelov
e18cb9748f ci: fix v check-md doc/docs.md 2022-04-15 20:25:19 +03:00
Delyan Angelov
173e6a943b checker: fix tests (adjust byte to u8 in .out files too) 2022-04-15 20:15:03 +03:00
Delyan Angelov
cc8803c602 builtin: fix failing embed_file_test.v (pub fn (data &u8) vbytes(len int) []u8 {) 2022-04-15 19:57:00 +03:00
Alexander Medvednikov
78cb6e2b41 all: handle fixed []u8 2022-04-15 18:35:56 +03:00
Alexander Medvednikov
1c6f63ac0a tests: use u8 everywhere 2022-04-15 18:34:15 +03:00
Alexander Medvednikov
fbb9e65c0f all: ~500 more byte=>u8 2022-04-15 18:25:45 +03:00
Alexander Medvednikov
ae6a25f44e websocket, utf: u8 fixes 2022-04-15 16:24:02 +03:00
Alexander Medvednikov
e97ebf8cfc sokol: byte => u8 2022-04-15 16:12:05 +03:00
Alexander Medvednikov
258d1f77dc net: fix byte buffers 2022-04-15 15:57:45 +03:00
Alexander Medvednikov
af73e195da net: byte fixes 2022-04-15 15:55:39 +03:00
Alexander Medvednikov
fb192d949b all: replace []byte with []u8 2022-04-15 15:35:35 +03:00
Alexander Medvednikov
0527ac633e ast: remove .byte 2022-04-15 15:30:37 +03:00
Alexander Medvednikov
dbcf6e9c33 os: fix Process on windows 2022-04-15 15:23:05 +03:00
Alexander Medvednikov
c14984899b builtin: fix windows fn definitions 2022-04-15 15:18:21 +03:00
Alexander Medvednikov
a1372e284c builtin: update alloc fn definitions 2022-04-15 15:16:10 +03:00
Alexander Medvednikov
c3ad4e2069 encoding.base64: use u8 2022-04-15 15:10:34 +03:00
Alexander Medvednikov
d4a0d6f73c all: byte => u8 2022-04-15 14:58:56 +03:00
Alexander Medvednikov
b49d873217 builtin: [1000]u8 fix 2022-04-15 14:48:39 +03:00
Alexander Medvednikov
014c3c97f0 all: byte => u8 2022-04-15 14:45:52 +03:00
Alexander Medvednikov
7f3b91e688 builtin: more byte => u8 2022-04-15 14:10:11 +03:00
Alexander Medvednikov
1e7eb713fb cgen: remove byte references from cheaders.v 2022-04-15 14:04:53 +03:00
Alexander Medvednikov
ba7b329c73 builtin: more byte=>u8 2022-04-15 13:55:56 +03:00
Alexander Medvednikov
e6ff1508d2 all: make u8 the primary type, byte the alias 2022-04-15 13:43:03 +03:00
Delyan Angelov
566f150b24 net.http: add parse_request_head/1, cleanup existing code 2022-04-15 10:33:44 +03:00
Delyan Angelov
c3ee4fb2a2 crypto: make public all Digest.checksum() methods 2022-04-15 09:02:42 +03:00
Alexander Medvednikov
3b36f16365 all: volatile globals 2022-04-15 02:39:38 +03:00
Alexander Medvednikov
0dff050735 builtin: u8/byte clean up 2022-04-14 16:43:34 +03:00
yuyi
2d6d6c9ac9 json: fix json decode with sumtype of multi array type (#14035) 2022-04-14 15:36:24 +03:00
yuyi
c4dff0d797 cgen: format the generated source code by gen_str_for_union_sum_type() (#14026) 2022-04-14 15:26:10 +03:00
yuyi
72c2dc805d cgen: fix error for generics struct that parent has str to string (#14037) 2022-04-14 15:23:50 +03:00
Delyan Angelov
f6c9a60f99 pref: only show the support cross compiler warning/VCROSS_COMPILER_NAME message for the C backend 2022-04-14 15:04:00 +03:00
Delyan Angelov
bf62b2e33e vfmt: stabilise the attribute sorting order (sort first by length of atributes, then in alphabetical order of their names) 2022-04-14 14:53:45 +03:00
Delyan Angelov
f1f75897b3 sync: use asserts in channel code only when -d debug is passed 2022-04-14 14:00:57 +03:00
Delyan Angelov
a62560d2c1 ci: fix generation of vc/v_win.c in gen_vc.yml 2022-04-14 13:44:18 +03:00
Delyan Angelov
e555335bf0 ci: fix windows-msvc builds, as well as the windows-cross job, turn on deprecation notices for [windows_stdcall] and [_fastcall] 2022-04-14 13:36:51 +03:00
fleur
68401d9dc8 gen: add callconv attribute for fn and type (#14027) 2022-04-14 11:29:52 +03:00
Delyan Angelov
5905590e78 builder, pref: use i686-w64-mingw32-gcc for cross compiling 32bit windows apps with v -m32 -os windows hw.v 2022-04-14 10:42:25 +03:00
Vincenzo Palazzo
48c295150f checker: fixes typechecking for a sum type with an alias type (#13974) 2022-04-13 18:38:26 +03:00
yuyi
dc08105022 json: fix error for json decode with sumtype (#14025) 2022-04-13 18:06:28 +03:00
Delyan Angelov
e5809363de docs: describe the contents of vlib/v/gen/c/testdata/ and how to write tests for the checker, that still do not have good codegen counterpart 2022-04-13 14:55:26 +03:00
Alexander Medvednikov
d7adb67d52 cgen: fix [cinit] 2022-04-13 02:55:47 +03:00
Alexander Medvednikov
2525a30b5f cgen: [cinit] attr for globals 2022-04-13 00:30:51 +03:00
yuyi
e3e5bef139 ast, parser: fix formatting of if with inline comments (fix #7796) (#14018) 2022-04-13 00:15:27 +03:00
Nick Treleaven
c780de6282 checker: disallow 'small_unsigned == signed' (#13967) 2022-04-12 19:37:30 +03:00
fleur
6718958058 cgen: add a [_fastcall] fn attribute (#14016) 2022-04-12 17:06:56 +03:00
牧心
a810fbb80e cgen: fix infix_expr_in_optimization compile error when treating some kind cannot directly use '==' (#14015) 2022-04-12 16:19:44 +03:00
Delyan Angelov
8788512c4d checker: make using err.msg and err.code produce an *actual* notice, even with the present compatibility hack (will be *removed* in 2022-06-01) 2022-04-12 14:56:02 +03:00
Delyan Angelov
4c7cdd2a2d checker,cgen: use faster sym.idx == ast.error_type_idx integer comparisons, instead of sym.name == "IError" 2022-04-12 14:49:51 +03:00
Delyan Angelov
62032c43db ast: fix Table.rewrite_already_registered_symbol calls (they were setting sym.idx to 0) 2022-04-12 14:49:51 +03:00
Delyan Angelov
9b43713ec5 net: simplify TcpListener.accept, use C.accept(l.sock.handle, 0, 0), since we do not care about the local address of the accepted connection 2022-04-12 11:47:41 +03:00
Delyan Angelov
716cb17aea math.big: wrap all asserts in module code (not in tests) in $if debug {} (#14012) 2022-04-12 09:38:53 +03:00
crthpl
afb07e0e16 cgen: fix deadlock when returning multiple values in lock (#14014) 2022-04-12 09:21:27 +03:00
yuyi
3e3b2e25db parser, fmt: fix the formatting of fn headers with inline comments (#14010) 2022-04-11 22:31:06 +03:00
Larpon
07207db998 examples: reduce C. prefix usage, rename fontstash enums (#14011) 2022-04-11 22:23:06 +03:00
Delyan Angelov
cb969e0934 tools: fix the behaviour of regress.v , when oldv.v is not compiled 2022-04-11 21:57:33 +03:00
Delyan Angelov
382586da6d ci: fix toml segfault (remove unused low level builtin option IError.msg compatibility hack) 2022-04-11 21:49:59 +03:00
Delyan Angelov
e64c8cce62 ci: bump size of EMPTY_STRUCT_DECLARATION's _dummy_pad field to 8 (a voidptr, instead of char) 2022-04-11 17:53:18 +03:00
yuyi
5551cb248c ast, parser, fmt: fix formatting of consts with embedded comments (#14008) 2022-04-11 17:27:41 +03:00
牧心
25d8faabf6 cgen: fix alloc empty struct array error (#14007) 2022-04-11 14:16:09 +03:00
Delyan Angelov
843ce43077 strconv: cleanup atof.c.v - use a ParserState enum, clarify comments 2022-04-11 12:01:47 +03:00
Delyan Angelov
e4dfffd70b toml: remove math import (used only for math.max and math.max_u32) 2022-04-11 10:22:31 +03:00
Nick Treleaven
1938bc48e7 toml.scanner: make end_of_text, at, next and peek return u32 (#13998) 2022-04-11 10:12:04 +03:00
yuyi
fa66183f43 checker: check error for map of generic struct init (#13999) 2022-04-11 10:07:23 +03:00
Delyan Angelov
a0e7a46be4 rand: speed up MT19937RNG.u64 2022-04-10 13:07:35 +03:00
Delyan Angelov
6c25f5b291 rand: fix needless array allocation in MT19937RNG.u64() 2022-04-10 13:02:31 +03:00
Subhomoy Haldar
3f90809035 rand: add missing pub modifiers for .byte() and .u32() methods (#13992) 2022-04-10 11:43:46 +03:00
牧心
11d9a67e3b cgen: fix invalid operands to an_alias in an_array_of_aliased_values (#13994) 2022-04-10 11:42:17 +03:00
Delyan Angelov
8517b8f8b0 examples: use #[] in news_fetcher.v to simplify the code 2022-04-10 11:11:53 +03:00
Delyan Angelov
88c4a64a15 examples: make examples/sokol/drawing.v more symmetrical 2022-04-10 10:40:14 +03:00
yuyi
93a5d03182 parser: improve embedded struct parsing/better error for Architecture []string (#13995) 2022-04-10 10:24:36 +03:00
Vincenzo Palazzo
3571f66a82 pref: fix access in invalid position on v search '' (#13993) 2022-04-10 10:21:58 +03:00
yuyi
473bc0254d checker: check error for array of generic struct init (#13987) 2022-04-09 21:50:34 +03:00
Delyan Angelov
89d64b21ea ci: remove manual free(f) in an autofree test, after 58febe46, which does it automatically now 2022-04-09 20:06:27 +03:00
Delyan Angelov
df30b79971 checker: allow for arr.any(opt_fn()?), add test 2022-04-09 19:50:10 +03:00
Daniel Oberhoff
58febe4607 cgen: fix autofree of heap variables (#13823) 2022-04-09 17:37:39 +03:00
yuyi
704e3c6e72 cgen: fix error for fn with fixed array argument (fix #13976) (#13982) 2022-04-09 15:57:27 +03:00
Nick Treleaven
bf385d2ac9 docs: add links to download C compilers (#13984) 2022-04-09 15:53:37 +03:00
pancake
804f2f56d4 vpm: support v install -once module_name(#13977) 2022-04-09 14:29:41 +03:00
pancake
e3da3101f6 vpm: simplify output for v list (#13975) 2022-04-09 14:26:01 +03:00
Delyan Angelov
60e718e7c6 test: save removing the nonexistent binary output for v fmt and v vet tests 2022-04-09 13:04:52 +03:00
Vincenzo Palazzo
2d867a2766 ast: fix reported errors, when arrays of types defined in modules are involved (#13952) 2022-04-08 17:38:34 +03:00
yuyi
2a88b313d4 cgen: format json encode/decode generated c codes (#13972) 2022-04-08 17:27:05 +03:00
yuyi
617608b23d cgen: fix optional struct declarations for empty structs (#13970) 2022-04-08 14:51:37 +03:00
Larpon
45a427e68b clipboard: fix segfault when pasting to some X11 apps. Fixes #13891 (#13971) 2022-04-08 13:32:38 +03:00
Larpon
52f1c615a6 fontstash: document all functions (#13969) 2022-04-08 13:22:23 +03:00
Joe Conigliaro
a0c07454b1 checker: remove debug code from previous commit 2022-04-08 18:27:14 +10:00
Joe Conigliaro
426e9d1734 checker: fix condition for checking if tmpl var is inherited 2022-04-08 18:25:08 +10:00
Joe Conigliaro
e1c8b07fa5 checker/tests: format test added in prev commit & rename chekcer prop 2022-04-08 17:41:23 +10:00
Joe Conigliaro
8dc2601080 all: comptime_call - simplify tmpl scoping, solves many issues. 2022-04-08 17:33:24 +10:00
mir.zhou
6425000ce4 example: fix the tuicool.com crawler example (changed html structure) (#13962) 2022-04-07 18:18:10 +03:00
Delyan Angelov
5a695c81dc ci: fix the recorded output for compare_structs.c.must_have after eea46c4 2022-04-07 18:08:56 +03:00
crthpl
b232a3b0d1 cgen: fix .filter() and .map() on shared arrays (#13954) 2022-04-07 18:05:11 +03:00
Delyan Angelov
eea46c4e1a cgen: fix error, when a struct with over 8 fields, is used as a method receiver directly. 2022-04-07 17:20:14 +03:00
Subhomoy Haldar
022fae1e7f rand: make mt19937 automatically seeded, add seed_len to wyrand (#13966) 2022-04-07 16:00:30 +03:00
Pascal Masschelier
95753ffb30 examples: fix process_stdin_trick example (#13953) 2022-04-07 13:55:12 +03:00
playX
6a820c2845 checker: allow all binary operations when translating code produced by c2v (#13964) 2022-04-07 12:22:24 +03:00
Vincenzo Palazzo
4666a27e5f ci: introduce v benchmarks inside the ci workflow (#13949) 2022-04-07 12:21:13 +03:00
Larpon
d34ef69229 tools: improve deprecation detection in missdoc.v (#13960) 2022-04-07 12:20:14 +03:00
yuyi
e7fd8c4e7c cgen: fix error for dereference mut interface in loop (fix #13913) (#13941) 2022-04-07 12:01:54 +03:00
yuyi
a58dde48f8 cgen: fix error for optional multi return (#13959) 2022-04-07 09:12:23 +03:00
yuyi
c9dcdf6744 cgen: fix json decode with optional argument (fix #13943) (#13958) 2022-04-06 19:34:22 +03:00
Larpon
56e6fd01c5 gg: document pub functions in text_rendering and m4/vector (#13961) 2022-04-06 19:34:02 +03:00
Delyan Angelov
c5d8d27b90 ci: fix -cstrict failures for vweb_test.v etc. 2022-04-06 08:54:01 +03:00
Vincenzo Palazzo
6412f8ba0b checker: add a known error on alias cast with generics (#13946) 2022-04-05 19:09:46 +03:00
Larpon
1482db6d1a gg: add missing doc strings to android, recorder and gg.c.v (#13936) 2022-04-05 18:42:01 +03:00
Vincenzo Palazzo
359f16fdfd parser: fixed parsing prototype function with recursive type (#13922) 2022-04-05 18:39:49 +03:00
yuyi
0cba579a7b cgen: simplify codegen for optional consts (#13948) 2022-04-05 17:54:23 +03:00
Delyan Angelov
2ecfd1b351 ci: fix clang sanitize errors for json_decode 2022-04-05 17:52:10 +03:00
Larpon
11ccf06441 time: add missing doc string to parse.v (#13933) 2022-04-05 13:21:37 +03:00
Larpon
2350dbbd57 gg: add missing doc strings to pub fns in image.* (#13934) 2022-04-05 13:21:03 +03:00
Larpon
0b046c14a8 clipboard: add doc strings to all implementations (#13932) 2022-04-05 13:06:32 +03:00
Delyan Angelov
f5e4d17cf3 json: return errors with more context, on failed json.decode() calls. 2022-04-05 12:06:08 +03:00
Alexander Medvednikov
829fed4af0 ci: build vpm again 2022-04-05 08:02:47 +03:00
Nick Treleaven
7d8db1042d vdoc: don't highlight less than expression as generic function (#13938) 2022-04-05 05:58:47 +03:00
yuyi
f6b8e1e13f cgen: fix error for const using nested optionals (#13939) 2022-04-05 05:58:11 +03:00
Delyan Angelov
0bd8fbc9a8 term, term.ui: fix a panic on !=linux unixes when running examples/term.ui/ 2022-04-04 19:25:25 +03:00
Nick Treleaven
2cd9c91e98 vdoc: highlight terminal examples for -comments -color (#13937) 2022-04-04 18:13:24 +03:00
Larpon
aa9e2ebb25 gg: document all draw functions (#13931) 2022-04-04 18:09:19 +03:00
pancake
5369379738 repl: handle exit(n) (#13930) 2022-04-04 16:22:34 +03:00
Alexander Medvednikov
92bfd9b353 cgen: fixed array index for translated code 2022-04-04 12:09:29 +03:00
StunxFS
725b472d37 checker: fix typos (#13929) 2022-04-04 10:07:53 +03:00
Nick Treleaven
91b40304b7 vdoc: highlight .., ... as punctuation & postfix ops as operators (#13924) 2022-04-04 09:21:54 +03:00
StunxFS
1211b2e941 v: minor change in the output for an unknown help topic (#13927) 2022-04-04 08:36:10 +03:00
Alexander Medvednikov
719a3b5de3 cgen: fix fixed arrays assignment in translated code 2022-04-04 06:20:54 +03:00
Alexander Medvednikov
a55e930c00 checker: fix pointer checks in translated code 2022-04-04 05:35:15 +03:00
Alexander Medvednikov
cc227d8520 checker: fix non-numeric type check for translated code 2022-04-04 04:59:14 +03:00
Nick Treleaven
d10135e2c4 vdoc: HTML highlight generic function as function, not name (#13923) 2022-04-03 23:41:02 +03:00
Delyan Angelov
44603f8e59 checker: add suggestions for misspelled mod.func_name() calls 2022-04-03 20:07:52 +03:00
Vincenzo Palazzo
51c1d666c2 checker: fix operator overloads (for large structs with > 8 fields, the method receiver is normally auto converted to a reference) (#13889) 2022-04-03 19:30:29 +03:00
StunxFS
38853568b4 encoding.csv: allow passing a custom delimiter to the new_reader function (#13910) 2022-04-03 19:13:43 +03:00
Nick Treleaven
782d5374c9 builtin: add an array.drop(n) method (#13907) 2022-04-03 17:05:50 +03:00
Delyan Angelov
a1e9cae5d2 tests: add a vlib/v/tests/known_errors/known_errors_test.v test runner 2022-04-03 12:54:22 +03:00
yuyi
0497b885dc checker: minor cleanup in find_unreachable_statements_after_noreturn_calls() (#13903) 2022-04-03 11:19:19 +03:00
yuyi
8c55a9ecd3 builtin: minor optimization of array.push() and array.push_noscan() (#13904) 2022-04-03 11:04:18 +03:00
Cameron Katri
340543dfc0 cli: add automatic manpage generation with -man (#13911) 2022-04-03 10:12:47 +03:00
Delyan Angelov
71dc6c224a tests: make vlib/net/udp_test.v more stable, and less noisy on the tests-sanitize-address-gcc job 2022-04-02 20:00:26 +03:00
Cameron Katri
d585fbea8a time: implement Time.strftime(fmt string) as a wrapper for strftime(3) (#13898) 2022-04-02 18:33:37 +03:00
Nick Treleaven
42f92db0ab v.doc: parse multi-line examples (so they get highlighted) (#13894) 2022-04-02 18:29:12 +03:00
yuyi
faa55b46de cgen: fix array of fixed array (fix #13895) (#13901) 2022-04-02 18:00:59 +03:00
yuyi
0bf0c73a49 checker: fix error for returning optional (#13902) 2022-04-02 17:25:01 +03:00
pancake
af79c1e6ef os: implement os.config_dir() like in Go's UserConfigDir (#13893) 2022-04-01 22:04:43 +03:00
Vincenzo Palazzo
d7817863c6 checker: type inference over a generic type should compile (#13824) 2022-04-01 19:31:27 +03:00
Delyan Angelov
9d2529b611 ci: reduce repetitions in test_global_mutex in init_global_test.v
With the old number of repetitions (2500000), that test alone could take over
30 seconds, in the CI environment.
2022-04-01 19:23:15 +03:00
yuyi
6987f2c087 time: fix error for time.local() on windows (#13892) 2022-04-01 17:16:46 +03:00
Vincenzo Palazzo
02c80bd445 time: fix repetitive time.now().local().local().local() offsetting the time further and further (#13861) 2022-04-01 00:11:17 +03:00
Nick Treleaven
9c1981a309 vdoc: show // comment prefix and hide any \x01 character (#13880) 2022-03-31 20:00:06 +03:00
yuyi
bc98c11d9d parser, checker, cgen: minor cleanup of go_expr() (#13875) 2022-03-31 19:58:04 +03:00
yuyi
db3bbb58cf cgen: fix error for cross assign of the reserved name variable (#13884) 2022-03-31 19:55:21 +03:00
Nick Treleaven
a87cd9663e vdoc: highlight inline examples for -f html (#13879) 2022-03-31 19:32:32 +03:00
R cqls
5c43493183 sokol: add support for compiling with -d darwin_sokol_glcore33 on macos (#13885) 2022-03-31 16:52:21 +03:00
Delyan Angelov
fb5df9665e ci: use ./v instead of v in "Shader examples could be build" step 2022-03-31 13:53:02 +03:00
Delyan Angelov
fa3fa2e74f ci: add again sudo apt-get update for the Install dependencies step 2022-03-31 13:44:42 +03:00
Cameron Katri
b15240185e builder,cgen: iOS fixes (#13883) 2022-03-31 11:51:13 +03:00
Delyan Angelov
4222fd0862 ci: add vlang/pdf testing task, simplify other_ci.yml using v should-compile-all 2022-03-31 11:35:20 +03:00
Delyan Angelov
74eabba52e tools: add a v should-compile-all examples/*.v examples/gg/ tool, to simplify CIs of V modules. 2022-03-31 11:13:20 +03:00
kylepritchard
6137ce23c0 math: allow acos(0) (fix #13876) (#13877) 2022-03-30 21:36:50 +03:00
yuyi
ae1cb5697e cgen: minor cleanup in ref_or_deref_arg() (#13874) 2022-03-30 21:06:38 +03:00
yuyi
d40a502981 checker: minor cleanup in fn_call() (#13873) 2022-03-30 21:05:17 +03:00
Delyan Angelov
61f078664c ci: entirely delete the Code CI / arm64-ubuntu-tcc Cirrus job, since it does not honor trigger_type: manual, but simply timeouts after severah hours, showing fake positives in the github CI 2022-03-30 16:00:01 +03:00
Subhomoy Haldar
7ef7188f4b math.big: add bit_len, optimize gcd, add documentation (#13872) 2022-03-30 15:52:09 +03:00
Delyan Angelov
8121a8ada0 ci,cgen: comment out including stdbool.h for now
Fails tcc tests on windows, see: https://github.com/vlang/v/runs/5749951315?check_suite_focus=true
and vlib/v/checker/tests/globals_run/function_stored_in_global.vv
2022-03-30 14:26:20 +03:00
Delyan Angelov
566735b298 cgen: add nil to c_reserved (it is a macro defined in MacTypes.h on macos) 2022-03-30 13:33:03 +03:00
Cameron Katri
093994655c v.builder: fix iOS compilation from non-macOS, allow -cc to override the default cross compiler (#13866) 2022-03-30 10:26:13 +03:00
Cameron Katri
3e69d3813b v.builder: fix linker flags for systems with Procursus (#13865) 2022-03-30 10:15:52 +03:00
Delyan Angelov
cc637e5ee8 checker: make the misssing shared/mut modifer in fn and method calls error clearer 2022-03-30 01:45:40 +03:00
yuyi
55d9464890 checker: fix error for marking as referenced (#13859) 2022-03-30 01:33:10 +03:00
yuyi
42a67831bf parser: fix printing slice of multiline raw string (#13856) 2022-03-29 18:06:11 +03:00
yuyi
c71770d9c5 checker: fix error for array of anon fn call (#13858) 2022-03-29 18:04:30 +03:00
Delyan Angelov
04cc037955 ci: fix -cstrict compilation of term.ui tests 2022-03-29 18:03:05 +03:00
Delyan Angelov
7ee93c8a20 docs: show the full information for deprecated functions 2022-03-29 15:17:55 +03:00
yuyi
fd34ebd84e checker: check the count of generics in fn arguments (#13855) 2022-03-29 10:04:19 +03:00
Delyan Angelov
4f551d76c0 term.ui: fix conflicting C struct declarations when compiling programs, importing term.ui before term, on windows 2022-03-29 09:31:24 +03:00
yuyi
509367b293 cgen: minor cleanup in expr_is_multi_return_call() (#13846) 2022-03-28 20:38:23 +03:00
Nick Treleaven
476f19c090 vdoc: tweak keyword, attribute and light theme CSS (#13853)
Make keywords bold.
Make attributes use a monospace font (like code).
Tweak light theme foreground colors:
* Make default-text, operator-text and punctuation-text a bit darker,
  improving the contrast.
* Make builtin-text a bit darker and more green (similar to dark theme).
* Make function-text a bit darker and more greeny-blue (similar to dark
  theme).
* Make attribute-text a bit less transparent for better contrast.
2022-03-28 20:38:00 +03:00
yuyi
dd1a8cbadc parser: check error for struct field type using 'mut' (#13847) 2022-03-28 18:13:38 +03:00
yuyi
62553dcc2e cgen: fix crash for casting bool to int (fix #13825) (#13844) 2022-03-28 12:20:47 +03:00
Nick Treleaven
c7a92425f0 doc: tweak built-in functions section & move dump section here (#13841) 2022-03-27 18:05:44 +03:00
Nick Treleaven
afdf8f50e7 doc: move enum methods to enum section from sum types (#13843) 2022-03-27 17:46:20 +03:00
Nick Treleaven
3a4bb09de2 doc: improve Arrays section (#13842) 2022-03-27 17:45:00 +03:00
Subhomoy Haldar
f75ce9dd82 rand: move functions from rand.util to the main module (#13840) 2022-03-27 17:38:59 +03:00
yuyi
875ad1f6ea ast: minor cleanup in ast.v (#13839) 2022-03-27 16:21:40 +03:00
Nick Treleaven
d748529337 doc: add links to notable array related subheadings (#13838) 2022-03-27 14:29:20 +03:00
Nick Treleaven
02f72c8230 builtin: improve docs for array methods that take an it expression, like .map, .filter etc (#13836)
Move explanation about boolean `it` expressions to `filter`, as `sort`
doesn't take a boolean expression. Also move `any` example.
Add 2 filter examples.
Add map example from docs.md.
2022-03-27 14:28:15 +03:00
Nick Treleaven
dc9fd2bd7e doc: tweak array methods section (#13837) 2022-03-27 14:26:23 +03:00
Delyan Angelov
a07d066e8f tools: cleanup all temporary files on successfull v check-md . 2022-03-27 10:24:10 +03:00
Delyan Angelov
0e496a8de2 tests: add an autofree regression test before return value ownership changes 2022-03-27 09:50:37 +03:00
Delyan Angelov
bea0d500d0 parser: ignore upper letter case restriction for fn C.xyz declarations 2022-03-26 21:20:28 +02:00
Nick Treleaven
fcb57312b9 parser: error if parameter name starts with a capital (#13827) 2022-03-26 19:56:34 +02:00
Delyan Angelov
8c396356bb context: make the examples in the vlib/context/README.md immediately runnable 2022-03-26 13:25:45 +02:00
Delyan Angelov
7f28d91190 ci: fix again -usecache regression on macos 2022-03-26 09:47:44 +02:00
Alexander Medvednikov
0248349e7c cgen: global/const fixes 2022-03-25 23:33:01 +03:00
Nick Treleaven
ea4410cdb5 builtin: document the rune.length_in_bytes method (#13826) 2022-03-25 20:09:39 +02:00
Delyan Angelov
347db755c8 tests: sort the test files before further processing in valgrind_test.v 2022-03-25 09:41:45 +02:00
Delyan Angelov
ddc2c49365 cgen: autofree out of scope variables in reverse order of their creation 2022-03-25 09:39:12 +02:00
Delyan Angelov
d6c40865f9 strings: cleanup unsafe casts in some of strings.Builder ops (#13819) 2022-03-25 00:07:15 +02:00
Delyan Angelov
5b492e26dd builtin: support a.flags.set(.noslices | .noshrink), use it in the particles example (#13818) 2022-03-24 23:37:13 +02:00
Nick Treleaven
a4ab3c1f14 checker: disallow mut_ptr = &immutable_var (#13814) 2022-03-24 20:43:25 +02:00
Delyan Angelov
9bbb52e9cc checker: add a check for dump(c), where typeof(c) == "char" 2022-03-24 12:11:59 +02:00
yuyi
78d9975798 ast, cgen: restore Type.str() and fix error for it (#13815) 2022-03-24 11:45:06 +02:00
yuyi
1566f7f766 checker: minor cleanup in check_types.v (#13816) 2022-03-24 08:59:05 +02:00
Delyan Angelov
5b668dba2b sync: document sync.thread_id() 2022-03-23 19:52:20 +02:00
Delyan Angelov
ce576d01c4 sync: add sync.thread_id() u64 { (#13810) 2022-03-23 19:19:14 +03:00
Nick Treleaven
2e963e36ac rand: add pub fn shuffle<T>(mut a []T) { function + tests (#13811) 2022-03-23 15:31:26 +02:00
yuyi
35cd8112a5 ast, checker, cgen: fix error for printing alias that has str method (#13809) 2022-03-23 11:52:48 +02:00
Vincenzo Palazzo
8b072aa962 checker: check if generic values have the same types (#13718) 2022-03-23 09:13:10 +02:00
yuyi
dff39bac78 cgen: fix error for defining global anonymous functions (#13808) 2022-03-23 08:09:15 +02:00
yuyi
e3dca82f9c strconv: minor cleanup in f64_to_str_lnd1() (#13804) 2022-03-22 20:15:59 +02:00
yuyi
0337882240 checker: check redefine global 'main' function (#13803) 2022-03-22 17:39:12 +02:00
Larpon
894080b844 ci: update sdl ci to compile shader example (#13805) 2022-03-22 17:36:23 +02:00
Ikko Ashimine
82120d02a8 tools: fix typo in vbug.v (#13802) 2022-03-22 15:47:03 +02:00
yuyi
a9837ba95d cgen: minor cleanup in go_expr() (#13801) 2022-03-22 12:07:46 +02:00
yuyi
56f5ed4789 strconv: fix error for string interpolation of float format (#13800) 2022-03-22 12:00:18 +02:00
Nick Treleaven
afbccf79f7 builtin: don't memdup element for array.pop (depends on how cgen works) (#13789)
The voidptr returned is immediately dereferenced in cgen so the memory
is copied before the array can be appended to: `*(int*)array_pop(&a)`
2022-03-21 23:34:35 +02:00
yuyi
f66d2f5d43 cgen: simplify in index_of_array() and add test (#13792) 2022-03-21 22:03:45 +02:00
Delyan Angelov
381cf4b61d ci: bump retries to 3, for flaky vlib/v/tests/go_array_wait_test.v 2022-03-21 21:47:01 +02:00
yuyi
c0437afbcd cgen: fix error for casting int to interface (#13790) 2022-03-21 21:18:11 +02:00
Delyan Angelov
9ad64b0bd8 vweb: support -d trace_request and -d trace_response 2022-03-21 19:48:47 +02:00
Delyan Angelov
178afd006b examples: avoid flash of unstyled content in the vweb_assets example 2022-03-21 19:13:53 +02:00
Delyan Angelov
3bae489e35 examples: make the vweb_assets.v example more robust (always change work folder to the folder of the executable). Document the vweb.Context.handle_static behaviour. 2022-03-21 19:05:18 +02:00
Delyan Angelov
f2e0ab5912 docs: add formatting example for "[${10.0000:.2f}]" 2022-03-21 14:42:18 +02:00
yuyi
5815ab8d00 cgen: minor cleanup in index.v (#13788) 2022-03-21 13:10:10 +02:00
yuyi
81bb1ea71f tests: cleanup go_anon_fn_variable_call_test.v (#13786) 2022-03-21 13:04:43 +02:00
El Koulali András
f5036629ca cgen: add true and false to C reserved words (#13781) 2022-03-21 11:00:30 +02:00
yuyi
d9cca53bd0 checker: check error for index of optional (#13785) 2022-03-21 10:17:57 +02:00
Delyan Angelov
21e9b1deb0 ci: fix -usecache failure on macos 2022-03-21 08:52:25 +02:00
Alexander Medvednikov
80c94ea73e cgen: fix c2v consts in .o files 2022-03-21 04:56:37 +03:00
yuyi
c4b424717c cgen: fix error for map get anon fn value (#13782) 2022-03-21 00:20:55 +02:00
Delyan Angelov
aaf87e04a2 tools: make the mini greeting text in the REPL more informative 2022-03-20 23:22:46 +02:00
Delyan Angelov
7216b5df11 tools: force showing V errors in color in interactive REPLs 2022-03-20 23:04:20 +02:00
Delyan Angelov
caa0e25939 cgen: fix struct type dependency sorting, when struct field types, are aliases to struct types from other modules (#13779) 2022-03-20 20:23:48 +02:00
Delyan Angelov
71edaa071a builtin: use malloc, instead of calloc in array.ensure_cap/1 2022-03-20 15:08:42 +02:00
yuyi
0a78847782 checker: check error for unknown type in anon fn field of struct (#13778) 2022-03-20 13:28:35 +02:00
yuyi
8c3687aa10 checker: check error for struct field init with nobody anon fn (#13777) 2022-03-20 13:04:31 +02:00
Delyan Angelov
8ab0bcb6aa Revert "builtin: improve performance for common array ops, based on VTune analysis"
This reverts commit 57db261538.
2022-03-20 12:57:27 +02:00
Delyan Angelov
57db261538 builtin: improve performance for common array ops, based on VTune analysis 2022-03-20 12:42:04 +02:00
yuyi
3e40cd5baa ast, checker, cgen: fix error for go anon fn variable call (#13776) 2022-03-20 07:45:23 +02:00
Delyan Angelov
c05634ebd1 ci: fix sanitize job failures after 02b889d 2022-03-19 21:45:58 +02:00
Delyan Angelov
02b889dac3 cgen: generate smaller switch statements for sumtypes/enums with else{} 2022-03-19 21:12:27 +02:00
Delyan Angelov
eb7c9cec3d parser: short circuit if conditions in Parser.name_expr 2022-03-19 20:31:03 +02:00
Delyan Angelov
4dd68d3965 ast: small cleanup of using simple string interpolation in a string builder .write_string/1 parameter 2022-03-19 17:25:53 +02:00
Delyan Angelov
0cc63107ff cgen: fix duplicate auto generation of free methods, add test 2022-03-19 01:01:08 +02:00
Delyan Angelov
ee6b23c2a7 toml: use toml.parse_text and toml.parse_file in the tests 2022-03-18 23:32:06 +02:00
yuyi
5237d1d446 cgen: fix error for empty interface (#13764) 2022-03-18 22:41:06 +02:00
Larpon
156efec278 toml: deprecate input.auto_config() and toml.parse() (#13770) 2022-03-18 22:33:51 +02:00
yuyi
3e41be1ff4 checker: minor cleanup in check_or_last_stmt() (#13763) 2022-03-18 22:27:53 +02:00
Delyan Angelov
1734e72638 v.vmod: make the v.mod parser more robust, show line numbers in errors, add tests 2022-03-18 22:23:11 +02:00
yuyi
5f79fa8a30 checker: handle invalid smartcast with if/match none ident or selector (fix #12317) (#13762) 2022-03-18 17:50:54 +03:00
Nick Treleaven
f903ef24e8 cgen: simplify slicing fixed array (#13767) 2022-03-18 17:50:30 +03:00
yuyi
bb2ddb98a3 parser: check if guard condition (#13765) 2022-03-18 17:49:20 +03:00
Delyan Angelov
54b0a2aa62 toml: fix toml.scanner.new_simple/1 to *always* create a scanner, based on text, not a file path 2022-03-18 16:14:44 +02:00
Delyan Angelov
0ca87ad09f parser: fix small performance regression after 1d83ab6b (by avoiding needless interpolation in hot paths) 2022-03-18 12:52:03 +02:00
Delyan Angelov
236bcda549 tools: speedup v fmt -verify when there are no file differences, avoiding diff.color_compare_files 2022-03-18 12:15:55 +02:00
Delyan Angelov
817bedec5d checker: show available sumtype variants in match branches on typos 2022-03-18 11:50:28 +02:00
Nick Treleaven
00563a130d cgen: fix double evaluation of rvalue array expression in slice (#13737) 2022-03-18 11:43:15 +02:00
ylluminate
d87b5d40b6 docs: add installation-issues discussion in README (#13761) 2022-03-18 11:32:56 +02:00
Hunam
8a2d3f6470 strings: add a Builder.ensure_cap() method (#13755) 2022-03-18 10:36:53 +02:00
yuyi
136f39a2d4 cgen: cleanup in if_expr() (#13754) 2022-03-17 01:09:49 +02:00
Delyan Angelov
7a4715288c checker: make the errors for call expression shared/mut mismatches more detailed 2022-03-16 22:45:35 +02:00
yuyi
7f62346213 cgen: fix error for if expr returning sumtype (#13752) 2022-03-16 15:43:17 +02:00
yuyi
315e07abf6 checker: minor cleanup in match_expr() (#13753) 2022-03-16 15:39:57 +02:00
yuyi
33167960ed checker: check the sumtype mismatch returned by match expr (#13751) 2022-03-16 09:31:38 +02:00
yuyi
57cba4d3f0 ast: minor cleanup in is_blank_ident() (#13748) 2022-03-16 09:30:37 +02:00
Delyan Angelov
089c93b613 x: add a mostly empty vlib/x/x.v file, to workaround a v doc bug
The bug is that `v doc` ignores README.md in a folder without .v files,
leading to tree nodes with empty # links and no content.
2022-03-15 20:19:39 +02:00
yuyi
49155ec312 parser: notice unnecessary parenthesis of reference (fix #11179) (#13739) 2022-03-15 16:11:53 +02:00
yuyi
92cafd8851 checker: check invalid 'mut' keyword in infix expr (#13742) 2022-03-15 14:50:17 +03:00
yuyi
1d83ab6be1 parser: check using invalid keyword with none ident (#13743) 2022-03-15 12:58:03 +02:00
playX
78b1cbefff builtin.wasm_bare: fix malloc invocation (#13740) 2022-03-15 12:55:39 +02:00
pancake
c5174c2c69 doc: fix minor typos in build-c (#13738) 2022-03-15 08:14:46 +02:00
Nick Treleaven
34dd4f34ab checker: fix cgen error on sliced references (#13736) 2022-03-14 19:52:37 +02:00
yuyi
ea3c0166c0 ast: fix error for typeof aggregate (#13735) 2022-03-14 18:42:47 +02:00
serg-meus
d6eb6d5bae doc: update struct access modifiers (#13734) 2022-03-14 18:38:36 +02:00
yuyi
dbb18e3656 parser: fix error for match branch with array expression (#13733) 2022-03-14 16:19:05 +02:00
pancake
a1d0db792e native: initial support for typeof() expressions (#13730) 2022-03-14 15:15:06 +02:00
kylepritchard
a8f6574471 math: allow i64 in digits function and add count_digits function (#13729) 2022-03-14 10:41:01 +02:00
playX
c8b0f51c13 builtin.wasm_bare: use walloc as malloc/free implementation (#13731) 2022-03-14 09:20:20 +02:00
Delyan Angelov
4d99157cd5 ci: add go2v build & test job to other_ci.yml 2022-03-13 19:03:42 +02:00
yuyi
f7feb634d2 checker: fix error for if mut with immutable variable (#13728) 2022-03-13 16:33:50 +02:00
Mihai Galos
9495aacf3e datatypes.fsm: add a fsm_graph.v tool (#13723) 2022-03-13 11:40:03 +02:00
Adam Oates
424ef0b2b8 stbi: fixed panic when trying to load JPG (#13724) 2022-03-13 09:57:34 +02:00
yuyi
27f9bc9ba0 checker: check error for match mut with immutable variable (fix #9704 #8976) (#13725) 2022-03-13 09:53:29 +02:00
Delyan Angelov
83762fa4a4 native: align the disassembly/comment column in the -v -b native output 2022-03-12 11:09:09 +02:00
Subhomoy Haldar
40504e8600 rand: further bridge gap b/w rand module and PRNG interface (#13719) 2022-03-12 09:41:12 +02:00
Delyan Angelov
a3e9409196 strconv: fix a double free bug in v_sprintf/remove_tail_zeros_old, reduce leaks 2022-03-11 19:32:08 +02:00
yuyi
795fe5844c strconv: fix strconv.v_printf() (#13716) 2022-03-11 17:00:57 +02:00
yuyi
10ab758aa7 ast: minor cleanup in pref_arch_to_table_language() (#13714) 2022-03-11 14:56:48 +02:00
Delyan Angelov
8dc4b1d9a3 builtin: use malloc_noscan more (for map metas and in []byte.hex()) 2022-03-11 11:26:22 +02:00
yuyi
1993bf2a12 parser: cleanup map syntax (#13713) 2022-03-11 12:15:52 +03:00
yuyi
c1c3ae2a18 parser: minor cleanup in fn_args() (#13711) 2022-03-11 10:42:03 +02:00
yuyi
3f351036a2 parser: fix error for fn with type only argument (fix #13704) (#13709) 2022-03-10 22:52:06 +02:00
yuyi
dd06698ee3 ast: rename TypeSymbol.is_public to TypeSymbol.is_pub (#13710) 2022-03-10 22:18:57 +02:00
Delyan Angelov
f3388df577 ci: fix dump_expression.vv when v is actually vprod (-‸ლ) 2022-03-10 18:13:00 +02:00
Delyan Angelov
e8c8f0e7c0 v.ast: fix dump(os.real_path(Makefile)) printing main.os.real_path 2022-03-10 11:24:46 +02:00
Nick Treleaven
4bea35b028 vlib/arrays: fix copy to not use memcpy for array, map, string (#13703) 2022-03-10 01:30:51 +03:00
JalonSolov
de2fc87995 os: handle trailing backslash on windows path when quoting (#13705) 2022-03-10 01:29:37 +03:00
Nick Treleaven
7231a3f135 vlib: add mut for the first parameter of builtin.copy, arrays.copy and crypto (#13702) 2022-03-09 20:26:00 +02:00
yuyi
4c33003f86 checker: check error for infix compare optional (#13701) 2022-03-09 20:20:21 +02:00
Nick Treleaven
54de04a916 arrays: improve fold/reduce docs (#13700) 2022-03-09 20:04:49 +02:00
yuyi
6c7243f2f7 checker: remove redundant 'c.expected_type = ast.void_type' (#13687) 2022-03-09 12:33:23 +02:00
Mihai Galos
d5b087de10 vlib: add a datatypes.fsm module (#13668) 2022-03-09 12:14:54 +02:00
pancake
3f1e232c9b native: support comparing two idents and avoid printing idents (#13686) 2022-03-08 19:52:30 +02:00
Delyan Angelov
10474f35f6 net.http: clarify error message in Request.ssl_do 2022-03-08 18:17:34 +02:00
Delyan Angelov
137fade014 Makefile: support CFLAGS and LDFLAGS for the vc/v.c to v bootstrap. 2022-03-08 14:48:20 +02:00
yuyi
3fe8204062 checker: fix if expr with enum value (#13685) 2022-03-08 11:55:17 +02:00
Delyan Angelov
f6aba9a3fe util: make check_module_is_installed more robust to ~/.vmodules paths with spaces 2022-03-08 11:33:03 +02:00
yuyi
cea3149369 checker: fix match expr with enum type value (#13683) 2022-03-08 09:50:17 +02:00
Nick Treleaven
17fcc788f2 arrays: add generic copy fn (#13677) 2022-03-08 09:44:04 +02:00
Delyan Angelov
beb1b8ce1b tools: add v scan file.v 2022-03-07 18:25:38 +02:00
pancake
b20c911d3e native: generate relocatable ELFs and support relative strings (#13671) 2022-03-07 18:24:01 +02:00
Subhomoy Haldar
0fd4c699dd tools: modify .gitattributes to categorize *.vsh and v.mod files properly (#13674) 2022-03-07 18:15:18 +02:00
yuyi
e6270b05dc checker: check unsigned integer compared with negative value (#13670) 2022-03-07 10:26:40 +02:00
Alexander Medvednikov
36ec47cd20 all: replace "NB:" with "Note:" (docs/comments) 2022-03-06 20:01:22 +03:00
Delyan Angelov
f74b65b63f docs: change term.input to term.ui in vlib/term/README.md 2022-03-06 15:50:22 +02:00
yuyi
c8e33ad219 cgen: fix error for array of reference auto_str (#13665) 2022-03-06 12:15:31 +02:00
Delyan Angelov
b0f651bf81 sync: enable tcc compilation of sync programs on Amazon Linux 2 (and other Red Hat distros like CentOS) by default (#13664) 2022-03-05 19:13:47 +02:00
yuyi
6380b9eb15 cgen: minor cleanup of struct.v (#13661) 2022-03-05 17:19:20 +02:00
yuyi
22fda7c3dd cgen: fix error for time struct init with update (#13660) 2022-03-05 13:28:48 +02:00
yuyi
8136157f87 checker: fix error for 'or expr with nested match expr' (#13658) 2022-03-05 13:06:08 +02:00
Ned
0e5ae7126f x/json2: fix decoder errors (#13655)
* x/json2: fix decoder errors, refactoring

* x/json2: add error-catching tests

* x/json2: add missing docs

* x/json2: fmt
2022-03-05 13:02:43 +02:00
kahsa
3ef437e679 sokol: reorder and add missing funcs (#13652) 2022-03-04 14:39:38 +03:00
Ned
437fa02f27 x.json2: add customized JSON output capability via Encoder (#13654) 2022-03-04 14:39:23 +03:00
Hunam
74d5106e8f cli: print cli errors in red where possible (#13647) 2022-03-04 12:28:11 +02:00
yuyi
f70e5bd69b parser: check assign expr with undefined variable (#13653) 2022-03-04 10:33:14 +02:00
ChAoS_UnItY
63b41e67fa v.parser: change body_start_pos to function declaration's lcbr, resolve #13642 (#13646) 2022-03-03 19:51:27 +02:00
Devin Bayer
9cc73fd0f8 docs: fix the .vsh doc example (#13645) 2022-03-03 19:47:05 +02:00
Delyan Angelov
4331d6dea0 v.builder: only add /DEBUG:FULL when -cflags does NOT contain custom /DEBUG options (#13643) 2022-03-03 16:47:41 +02:00
yuyi
a98eebde7f checker: add a notice for potentially incorrect smartcasts (#13644) 2022-03-03 16:36:40 +02:00
kahsa
1e76cccd48 doc: add a struct reference example (#13638) 2022-03-03 13:20:49 +02:00
yuyi
ac1b31dbba checker: fix error for array of interface init in for_in (#13636) 2022-03-03 12:32:55 +02:00
Delyan Angelov
3364f2aadf cgen: use ADDR for sumtype conversion instead of HEAP (fix regression after 7f8f571) 2022-03-03 11:44:24 +02:00
yuyi
288b13b51d all: cleanup smartcasts in the compiler (#13639) 2022-03-03 10:48:31 +02:00
Delyan Angelov
4e7db5bab0 v.builder: streamline get_os_cflags/0, use pref.os_from_string to centralise string -> v.pref.OS conversion 2022-03-03 10:43:50 +02:00
ChAoS_UnItY
6a3d34ae11 checker: fix #13626, when unwrapped type is fixed array, and selector expr is 'len' (#13627) 2022-03-02 20:46:18 +02:00
Delyan Angelov
57c6454656 ci: bump timeout-minutes to 30 for 'Bootstraping works' job 2022-03-02 19:51:40 +02:00
yuyi
36e80266e6 ast: fix error for 'for smartcast' - part 2 (#13635) 2022-03-02 16:01:20 +02:00
yuyi
ffe6ff3cc8 cgen: fix error for print smartcast variable (#13634) 2022-03-02 12:32:54 +02:00
yuyi
22017ff8f4 parser: fix error for 'for smartcast' - part 1 (#13629) 2022-03-02 12:18:03 +02:00
yuyi
7f8f571ed2 cgen: fix error for optional cast to interface (#13623) 2022-03-01 19:21:55 +02:00
kahsa
6d57315aca net: fix html dom debug print (#13625) 2022-03-01 19:20:40 +02:00
Ikko Ashimine
aa633dab41 utf8: fix typo in utf8_util.v (#13624) 2022-03-01 19:06:48 +02:00
Delyan Angelov
fd91811fe2 v.util: add set_source_for_path/2 to enable external tools to use util.formatted_error on pathless sources 2022-03-01 18:55:25 +02:00
yuyi
996bd41ce8 checker: simplify for smartcast in for_stmt() (#13619) 2022-03-01 12:31:48 +02:00
Joe Conigliaro
3b6e122d9d all: comptime_call - update tmpl scope vars with caller scope vars after their properties got updated in checker 2022-03-01 02:13:29 +11:00
yuyi
0028e557f9 checker: cleanup smartcast in checker.v (#13618) 2022-02-28 17:06:37 +02:00
yuyi
9a2df0df0e cgen: fix fn mut argument of interface type (#13616) 2022-02-28 13:31:04 +02:00
yuyi
013589e9fe parser: minor cleanup in global_decl() (#13617) 2022-02-28 13:30:17 +02:00
Subhomoy Haldar
a0d9e6e1c2 rand: extend PRNG interface, add buffering support (#13608) 2022-02-28 13:17:54 +02:00
yuyi
efeb3e04da ast: add table.is_sumtype_or_in_variant() (#13615) 2022-02-28 11:38:20 +03:00
yuyi
81c787ef91 checker: fix match expr with assign sumtype variable (#13614) 2022-02-28 11:37:59 +03:00
yuyi
bc16c61f6f parser: check using 'mut' on fn_decl return type (#13610) 2022-02-27 14:23:43 +02:00
yuyi
0fb1eaef04 parser: check the redefinition of built-in IError (#13606) 2022-02-26 09:52:40 +02:00
Mihai Galos
4215bb125c examples: improve the sendbus example (#13604) 2022-02-26 09:50:44 +02:00
yuyi
0d9792bdf2 ast: cleanup in find_method_with_generic_parent() (#13600) 2022-02-26 02:11:56 +03:00
Larpon
d80f5165dd fmt: keep trailing comments after fn header decl (#13596) 2022-02-25 16:36:48 +03:00
yuyi
83ea97b1a3 parser: fix optional expr with array value (#13599) 2022-02-25 15:54:12 +03:00
Larpon
73f931b52e fmt: improve single line const comment placement (#13595) 2022-02-25 14:46:12 +02:00
Delyan Angelov
9535d38645 ci: fix concurrency.group name for containers_ci.yml 2022-02-24 16:00:57 +02:00
Bastian Buck
fa645516c3 crypto: implement Output Feedback (OFB) Mode for AES and DES (#13583) 2022-02-24 14:38:21 +02:00
Bastian Buck
0d07a64230 crypto: implement Counter (CTR) Mode for AES and DES (#13582) 2022-02-24 12:06:33 +02:00
Delyan Angelov
9523c23e14 ci: bump timeout-minutes to 25 for ci_cross.yml 2022-02-24 12:04:04 +02:00
yuyi
d30ad344e8 checker: check error for array of sumtype appendding (#13593) 2022-02-24 11:07:03 +02:00
kahsa
f6891c405a doc: fix header size (#13594) 2022-02-24 10:51:10 +02:00
yuyi
a28249c119 ast: fix for in iterator of generic struct (fix #13579) (#13585) 2022-02-24 10:48:52 +02:00
kahsa
9662b79662 doc: improve embedded struct section (#13574) 2022-02-23 15:54:00 +02:00
Subhomoy Haldar
114a341f5f rand: simplify rand.PRNG, move to optional types for error handling (#13570) 2022-02-23 12:36:14 +02:00
Bastian Buck
5c0b7b0d05 crypto: implement Cipher Feedback (CFB) Mode for AES and DES (#13566) 2022-02-23 11:55:16 +03:00
yuyi
b5e7cef1b1 ast: define 'const invalid_type_idx = -1' (#13573) 2022-02-23 11:54:43 +03:00
yuyi
c3ec738126 checker: check struct field reference type mismatch (#13575) 2022-02-23 11:53:22 +03:00
gcxfd
838a8f2183 docs: improve the documentation for struct embedding (#13560) 2022-02-22 19:09:54 +02:00
mahdi ramezaan zaade
2712e43802 doc: add an example on how to get a cloned slice (#13567) 2022-02-22 17:22:33 +02:00
Delyan Angelov
d2e8302d21 ci: show failing compilation output in draw_fns_api_test.v (make diagnostic easier) 2022-02-22 16:53:06 +02:00
yuyi
6486fffc5a checker: cleanup map = {} processing (#13563) 2022-02-22 16:04:54 +02:00
Vincenzo Palazzo
6a876d4170 datatypes: small fix for the BST node constructor (#13569) 2022-02-22 15:41:30 +02:00
Larpon
1032cf5c04 checker: only cast as ast.Var if not unresolved, fixes #13561 (#13562) 2022-02-22 15:23:15 +02:00
Delyan Angelov
33d379d530 ci: vfmt vlib/net/socket.v 2022-02-22 15:21:20 +02:00
gcxfd
ee1de06678 net: extract a common Socket struct, reuse it by embedding in TcpSocket & UdpSocket (#13559) 2022-02-22 10:34:38 +02:00
Vincenzo Palazzo
7bd8503170 datatypes: add a binary search tree implementation (#13453) 2022-02-22 10:28:01 +02:00
Delyan Angelov
4a765bc33b cgen: support -d trace_gen_source_line_info 2022-02-21 23:04:10 +02:00
Delyan Angelov
f2e5bb447e os: remove dead code 2022-02-21 22:57:24 +02:00
yuyi
07e9ed1a1d cgen: fix interface embedding method call (#13553) 2022-02-21 17:49:38 +02:00
playX
b842e89acc all: initial implementation of compile-time types (#13549) 2022-02-21 17:42:54 +02:00
yuyi
83cdd8bedd ast: add comments for struct 'StructInit' and 'StructInitField' (#13551) 2022-02-21 12:48:53 +02:00
simon place
8ba4a3dd01 math.complex: make mutable the Complex.re and Complex.im fields (#13540) 2022-02-21 12:39:45 +02:00
kahsa
809772db4e gg: improve Context scale for Android (#13545) 2022-02-21 12:12:21 +02:00
gcxfd
8b033c3993 tools: add a -theme-dir folder/ parameter to v doc (#13550) 2022-02-21 12:08:46 +02:00
yuyi
04654ed518 parser: check error for defer propagate (fix #13534) (#13536) 2022-02-20 12:29:08 +02:00
yuyi
75ebac006d cgen: fix struct init with multi nested embed update expr (#13529) 2022-02-19 20:46:44 +02:00
gcxfd
dbae2d6af4 net: add UdpSocket.address() method (#13524) 2022-02-19 20:45:55 +02:00
yuyi
09f08e1fee cgen: fix error for interface and embedded struct build (#13530) 2022-02-19 20:43:40 +02:00
eyun
67e33bf9bc checker: make public the valid_comptime_if_os list (#13518) 2022-02-19 15:22:33 +02:00
eyun
2b974cdb97 docs: rename exec -> execute (#13514) 2022-02-19 15:20:46 +02:00
yuyi
0236931c78 cgen: fix generics with reference generic arguments (#13525) 2022-02-19 15:19:50 +02:00
Alexander Medvednikov
3fa6622ee8 doc: simplify the filter/map example a bit 2022-02-19 12:10:12 +03:00
Dialga
bcc4de19fc v.builder: fix cross compiling directory with spaces (#13522) 2022-02-19 10:08:41 +02:00
yuyi
0208e9672d checker: check array sort_with_compare callback function parameters (#13511) 2022-02-19 10:06:36 +02:00
Milo
4cdb244151 docs: update urls in roadmap (#13509) 2022-02-18 14:19:06 +02:00
Delyan Angelov
d86b18844e net.unix: use byte() instead of u16() cast for addr.sun_family 2022-02-18 13:47:12 +02:00
Delyan Angelov
fad254dcce ci: skip use_net_and_net_unix_together_test.v on windows 2022-02-18 12:45:32 +02:00
Delyan Angelov
3c38abc56e rand: fix rand.uuid_v4()'s clock_seq_hi_and_reserved field 2022-02-18 12:43:38 +02:00
Delyan Angelov
c9867a9ae4 net: ensure that net and net.unix can be imported together in the same program 2022-02-18 11:47:56 +02:00
yuyi
14073ac0fe checker: fix error for array of sumtype init (#13501) 2022-02-18 11:47:24 +02:00
Subhomoy Haldar
072480352c math.big: add get_bit, set_bit, big_mod_pow (#13507) 2022-02-18 11:53:39 +03:00
Delyan Angelov
a886242700 ci: extract ubuntu-docker-musl and alpine-docker-musl-gcc to containers_ci.yml, so they can be easily turned on/off in private github actions 2022-02-18 10:31:01 +02:00
Delyan Angelov
3bcd11260f ci: move alpine-docker-musl-gcc and ubuntu-docker-musl to other_ci.yml 2022-02-18 10:25:04 +02:00
Delyan Angelov
ef5ea0ef21 ci: fix vweb failures (restore the ability to *force* vweb to listen to *only* local interfaces) 2022-02-18 10:18:04 +02:00
Alexander Medvednikov
3d46005195 tools/fast: bring back -usecache 2022-02-18 10:41:53 +03:00
Joe Conigliaro
f4051e0252 checker: make sure generic struct instantiation uses a known type. closes #13506 2022-02-18 17:54:52 +11:00
Anton Zavodchikov
da9331f8ff vweb: support ipv6 (#13498) 2022-02-17 23:13:36 +03:00
Delyan Angelov
eb45a321a5 tools: add cmd/tools/regress.v to simplify bisecting for regression bugs/features:
Support finding which commit introduced a regression:
       ./v run cmd/tools/regress.v --old COMMIT --command './v run /abs/path/to/regression_bug.v'

   Support also finding which commit introduced a feature (or made code compile/run):
       ./v run cmd/tools/regress.v --old COMMIT --command '! ./v run /abs/path/to/feature.v'

   NB: the '! ' is a POSIX shell feature. It may not work on Windows outside of WSL.
   Its meaning is to invert the exit code for the next command, i.e. 0 -> 1, non 0 -> 0

   If it does not work for you, you need to write a more explicit script that will exit
   with 0 code for all commits, where the feature does NOT work, and with non 0 code for
   all commits, where the feature does work.
2022-02-17 18:07:28 +02:00
Joe Conigliaro
d739abbb3f cgen: move var decl out of loop in global_decl() 2022-02-18 00:42:54 +11:00
Delyan Angelov
ebb66aa82c tools: support git bisect run cmd/tools/oldv --bisect --command "./v run /abs/path/to/regression.v" 2022-02-17 15:34:55 +02:00
Delyan Angelov
554a689213 ci: be more verbose when running make.bat on the CI 2022-02-17 13:26:23 +02:00
Joe Conigliaro
07b15a209a cgen: fix for prev commit - get usecache working with clang (fix duplicate symbols) 2022-02-17 22:24:58 +11:00
Joe Conigliaro
6fc654821f cgen: get usecache working with clang (fix duplicate symbols) 2022-02-17 22:17:07 +11:00
Delyan Angelov
245b70cabc checker: bump iface_level_cutoff_limit to 100 (fix ci) 2022-02-17 11:46:04 +02:00
Delyan Angelov
230dc26858 checker: bump iface_level_cutoff_limit to 99 (fix ci) 2022-02-17 11:42:34 +02:00
yuyi
4f9039991f parser: cleanup in check_undefined_variables() (#13496) 2022-02-17 10:16:52 +02:00
Delyan Angelov
901a4d8b84 checker: restrict too deep recursion, to prevent stackoverflows on windows
For v itself, the nesting levels do not exceed 15, so a limit of 40 seems reasonable.
2022-02-17 10:04:11 +02:00
yuyi
842fd7a27e parser: check assign expr with undefined variables of struct_init (#13495) 2022-02-17 10:21:03 +03:00
Delyan Angelov
89b99ad4c3 scanner: remove the restriction for \x00 in strings (#13493) 2022-02-16 23:41:05 +02:00
blackshirt
54b10e99a1 ed25519: make public ed25519.internal.edwars25519.Element (#13488) 2022-02-16 22:56:14 +02:00
Tarcisio Gruppi
f68144774d fmt: fix map missing a comma after enum keys, leading to non parsable code (#13481) 2022-02-16 21:08:29 +02:00
Delyan Angelov
d3b8ac2e46 ci: remove the -silent flag for CI jobs (the failing tests are listed at the end of the run anyway) 2022-02-16 21:02:36 +02:00
yuyi
f8b8950b96 checker: check mut interface arguments (#13479) 2022-02-16 11:53:41 +02:00
Alexander Medvednikov
5a14748e7c cgen: c2v enum fix 2022-02-16 12:05:32 +03:00
Delyan Angelov
9c24d09dc3 strconv: bug fix for "${239.5:0.0f}" (#13483) 2022-02-16 11:33:29 +03:00
starryskye
6d2a88e31f net.smtp: add STARTTLS and implicit SSL support (#13473) 2022-02-16 09:18:51 +02:00
vyrus001
d4fc8601e0 builder: fix clang failing to link on windows due to an -ftlo error (#13470) 2022-02-16 09:13:26 +02:00
Mihai Galos
b8d656b308 examples: enhance the call_v_from_python example, with a fn accepting 2 f64 params (#13480) 2022-02-16 09:12:49 +02:00
blackshirt
3ac4155f0c crypto: add an ed25519 digital signature module (#13476) 2022-02-15 21:28:14 +02:00
Delyan Angelov
ff34b79d39 crypto: implement rand.bytes(needed_bytes int) ?[]byte, use it consistently instead of the old rand.read(), which will change to be compatible with io and the pseudo random rand module 2022-02-15 18:39:33 +02:00
Larpon
80444c8ec4 strings: add find_between_pair (#13468) 2022-02-15 15:12:15 +02:00
Delyan Angelov
d25652fbcf parser, ast: support -d for trace_rewrite_already_registered_symbol, trace_register_sym, trace_parse_stmt, trace_parse_comptime, trace_parse_text, trace_parse_file, trace_parse_vet_file 2022-02-15 13:20:40 +02:00
yuyi
fb3dd82400 cgen: fix interface embedding complex cases (#13472) 2022-02-15 12:41:40 +02:00
mint
73cf597bec ci: remove now-useless mlibc stuff from Vinix workflow (#13471) 2022-02-15 11:19:28 +02:00
yuyi
f9fc136c24 all: rename InterfaceDecl.ifaces to InterfaceDecl.embeds (#13475) 2022-02-15 11:17:39 +02:00
crthpl
e23db2f9b7 cgen: fix autogen free method for struct with shared field (#13469) 2022-02-15 03:55:06 +02:00
Delyan Angelov
89e9f8a00c ci: fix vinix compilation to commit aa18fc0 (Meson building mlibc fails in a01546b) 2022-02-14 21:25:50 +02:00
yuyi
dc0b0c83c6 ast: fix error for interface embedding call (#13466) 2022-02-14 19:22:44 +02:00
Delyan Angelov
f8bf3db568 markused: always include slice_ni & substr_ni too (support s#[] and a#[] in -skip-unused) 2022-02-14 19:05:30 +02:00
igor
efdbe9d92c repl: fix list command deleting '/'; adapt the logo to the terminal size (#13462) 2022-02-14 16:18:20 +02:00
yuyi
8119a297f7 ast: fix error for 'struct embed is interface' (#13465) 2022-02-14 13:43:36 +02:00
yuyi
b2f984280b checker: strengthen the judgment of generic type parameters replacement, merge generic type init tests (#13460) 2022-02-14 02:38:47 +02:00
yuyi
2e0f8ee9e2 ast: fix error for struct embedding with interface (#13457) 2022-02-14 02:33:47 +02:00
Vincenzo Palazzo
bf11df40e2 readline: give the possibility to ignore the empty line in the history (#13452) 2022-02-14 00:12:25 +02:00
blackshirt
57e850e932 crypto.sha512, crypto.sha256 : Make public the write() and sum() methods (#13461) 2022-02-14 00:10:50 +02:00
Delyan Angelov
74048e2f17 net: simplify the TcpConn.read_line/0 method, accumulate partially read lines, use a string builder, instead of concatenation 2022-02-13 22:42:38 +02:00
Vincenzo Palazzo
6ea4f361a1 urllib: fixed regression in the set function (#13455) 2022-02-13 15:06:00 +02:00
igor
9ff0c51e61 repl: reduce the vertical size used by V's logo, put it on the left of the info texts (#13451) 2022-02-13 11:41:36 +02:00
Delyan Angelov
bad30bdd79 os: allow using XDG_CACHE_HOME for choosing the folder returned by os.cache_dir() on windows too 2022-02-13 11:18:51 +02:00
yuyi
5071a54b99 cgen: split up into for.v, match.v, struct.v (#13454) 2022-02-13 07:52:49 +03:00
yuyi
b5379255da checker, cgen: fix error for struct embed with fn type (#13450) 2022-02-12 20:55:40 +02:00
Ulises Jeremias Cornejo Fandos
4391ae563d examples: improve the pendulum simulation, with several modes and diagrams (#13446) 2022-02-12 19:38:07 +02:00
Delyan Angelov
a74d28ae5f sync,ci: bump vtest retry for channel_select_6_test.v 2022-02-12 19:22:27 +02:00
Delyan Angelov
799c95dc4e tests: filter test_ fns with params from the list of automatically run test functions (fix #13443) 2022-02-12 17:30:20 +02:00
Delyan Angelov
11a0df5bee tests: rename struct_with_reference_alias_field.v to struct_with_reference_alias_field_test.v 2022-02-12 15:29:22 +02:00
crthpl
0eee012ae9 cgen: fix x in shared_map (#13442) 2022-02-12 11:55:25 +02:00
Tim Basel
37c151efe5 docs, builtin, encoding.csv: update error implementations (#13440) 2022-02-12 11:54:10 +02:00
yuyi
ae0e90f5d8 cgen: fix struct init with embed field update (#13444) 2022-02-12 08:16:51 +03:00
yuyi
7178367de0 all: fix error for comptime for in field with generic fn (fix #13409) (#13439) 2022-02-11 22:00:13 +02:00
Tim Basel
9d0a5942ac builtin: change IError msg and code to methods + fix vlib, add a deprecation notice for the old usages (#13041) 2022-02-11 15:52:33 +02:00
Vincenzo Palazzo
61024d4b75 repl: support aliased module imports too (#13423) 2022-02-11 15:03:14 +02:00
Juergen Donnerstag
654bc49d3c os: implement win_read_string on os.Process (#13428) 2022-02-11 13:02:00 +02:00
Artem
e0618f94e8 v help: add an example of using both -prof and run (#13432) 2022-02-11 11:24:07 +02:00
yuyi
a21f4563b3 checker: check the arity and the kinds of the type parameters in generic struct inits (#13429) 2022-02-11 11:21:07 +02:00
Vincenzo Palazzo
7f29418c63 strconv: change atof64 to return an error, if the parsed value is not a valid number (#13424) 2022-02-10 13:27:32 +02:00
Delyan Angelov
1c19573382 ci: use 'trigger_type: manual' for Cirrus CI's arm64_task/arm64-ubuntu-tcc job 2022-02-10 13:22:18 +02:00
kahsa
b205e2fc67 docs: improve the interface examples (#13422) 2022-02-10 12:28:40 +02:00
Delyan Angelov
9ed18efa53 checker: error on redefining any of the public builtin functions, not just ['print', 'println', 'eprint', 'eprintln', 'isnil', 'panic', 'exit'] (#13419) 2022-02-10 12:26:30 +02:00
Artem
43d6b97c21 docs: improve the hot reload section, add run command example (#13418) 2022-02-09 19:26:09 +02:00
yuyi
f2eb50008d parser, checker: cleanup struct short syntax processing (#13416) 2022-02-09 18:31:16 +02:00
Vincenzo Palazzo
0d1d259bb4 net.urllib: keep the query parameter order (#13405) 2022-02-09 17:36:12 +02:00
yuyi
4be3c92640 checker: check generic struct init without type parameter (#13404) 2022-02-09 14:06:45 +02:00
Delyan Angelov
356ccf247f cgen: add an earlier error, to pin point the use of closures on windows 2022-02-09 08:35:11 +02:00
Delyan Angelov
dd835acb8d sync: add Once.do_with_param/2 method in addition to the existing Once.do/1 (workaround the absence of closures on windows) 2022-02-08 17:15:28 +02:00
Subhomoy Haldar
5d2995c4d5 tools: support ./v symlink -githubci (#13403) 2022-02-08 13:23:10 +02:00
Delyan Angelov
1dbde05267 ci,tools: improve the precision of report-missing-fn-doc, remove dependence on sed 2022-02-08 11:30:13 +02:00
Delyan Angelov
ff02f94fd6 tools: support --exclude/-e and --relative-paths/-r options in missdoc.v 2022-02-08 11:10:19 +02:00
Snavy
f0806822dd docs: add a JSON section, and subsections for encoding and decoding (#13396) 2022-02-08 10:18:40 +02:00
playX
4ef7d26133 arrays: add rotate_left and rotate_right (#13388) 2022-02-07 13:20:45 +02:00
Larpon
5df83812a0 ci: fix undoc pub fn diff output (#13389) 2022-02-07 13:18:10 +02:00
Vincenzo Palazzo
10dcb2e0d9 parser: allow embedding interfaces from other modules (#13385) 2022-02-07 00:20:34 +02:00
Delyan Angelov
1dc239227d docs, builtin: clean up the homepage of modules.vlang.io a little, do not use //==== comments for now in builtin 2022-02-06 23:51:40 +02:00
Delyan Angelov
7f70493e1d vdoc: show the V commit hash too, not just 0.2.4 2022-02-06 23:50:11 +02:00
Delyan Angelov
191e99c248 v.doc: use the .parse_comments mode, instead of the older .toplevel_comments (the scanner/parser is now more robust) 2022-02-06 23:49:21 +02:00
Larpon
649ecab11f ci: add report-missing-fn-doc job, to prevent adding new undocumented pub symbols in vlib (#13386) 2022-02-06 19:52:14 +02:00
Vincenzo Palazzo
d46ac40758 checker: add error for assigning none values (#13383) 2022-02-06 16:08:23 +02:00
Larpon
31df2c4f45 tools: tweak missdoc defaults, add CLI flags to control what's ignored (#13384) 2022-02-06 15:44:26 +02:00
kahsa
fd9aa8bee6 ci: require a minimal reproducible code sample in .github/ISSUE_TEMPLATE/bug_report.md (#13382) 2022-02-06 15:41:57 +02:00
Delyan Angelov
1be0cb0306 ci: do not fail silently in the Cirrus CI / Code CI / arm64-ubuntu-tcc job 2022-02-06 14:18:24 +02:00
div72
939bc9f26f v.parser: fix compilation of normal .v files with -translated (#13363) 2022-02-06 12:53:20 +02:00
Ikko Ashimine
31739c2586 docs: fix typo (#13381) 2022-02-06 11:39:35 +02:00
Delyan Angelov
66f21cae55 rand: add pub fn rand.read(mut buf []byte) and pub fn rand.bytes(needed int) ?[]byte{} + tests 2022-02-06 10:54:34 +02:00
yuyi
ece73836aa cgen: fix error for struct with reference alias field (#13380) 2022-02-06 10:52:36 +02:00
Vincenzo Palazzo
4e13ee22e9 repl: reproduce the void print function error (#13372) 2022-02-06 08:05:25 +02:00
Alexander Medvednikov
f23d2c8cf4 cgen: c2v variadic fixes 2022-02-06 03:36:38 +03:00
div72
cec7e91714 v.parser, v.checker, v.gen: add support for [translated] tag (#13373) 2022-02-06 00:16:02 +02:00
Sandro Martini
054c8b1f13 log: update Logger interface, so that Log is usable even as a Logger instance; add a test to ensure it (#13376) 2022-02-05 22:09:55 +02:00
Delyan Angelov
5faabe7464 Revert "cgen: fix error for struct with reference alias fields (#13374)"
This reverts commit 4d485ae687.
2022-02-05 18:52:37 +02:00
yuyi
4d485ae687 cgen: fix error for struct with reference alias fields (#13374) 2022-02-05 18:23:54 +02:00
Asher
47ee292ba4 vweb: make Context.mount_static_folder_at more robust (#13361) 2022-02-05 15:10:26 +02:00
yuyi
173b4652fb parser: check orm sql statements, using undefined variables in where expr (fix #13367) (#13368) 2022-02-05 11:32:41 +02:00
Vincenzo Palazzo
c9a8d6448d fmt: preserve formatting with comments in a empty map (#13362) 2022-02-05 10:05:35 +02:00
Vincenzo Palazzo
b9fce4ef09 checker: make sure that the operator check is made on the concrete type (#13360) 2022-02-05 00:11:24 +02:00
Delyan Angelov
a054f868a0 v.util: use a normalised relative file path in the error messages with /, even on windows, to make the compiler error tests more robust 2022-02-04 17:56:08 +02:00
Delyan Angelov
d02c0636d8 encoding.hex: fix shift warning 2022-02-04 15:16:08 +02:00
yuyi
a61b4809dc ast, parser, checker: fix generic struct init with inconsistent generic types (#13359) 2022-02-04 14:24:38 +02:00
Delyan Angelov
89d399b035 examples: fix leak in examples/sokol/particles/, by marking s.pool and s.bin with .noslices 2022-02-03 18:52:52 +02:00
Delyan Angelov
85d36ed231 checker: stricter type casting error messages 2022-02-03 14:18:30 +02:00
kahsa
ede9f29323 doc: mention []rune.string() (#13348) 2022-02-03 11:29:02 +02:00
yuyi
be1e40dac0 cgen: fix error for sql statement inside fn call (fix #13330) (#13346) 2022-02-02 18:05:31 +02:00
Delyan Angelov
9344c27021 builtin: save a call to array.ensure_cap in array.insert, array.push, array.push_many in most cases 2022-02-02 11:01:07 +02:00
crthpl
c0c07db7cc cgen: fix struct field init from shared struct field (#13343) 2022-02-02 10:55:57 +02:00
penguindark
c3573454d1 regex: fix bug in replace_by_fn (#13344) 2022-02-02 10:52:18 +02:00
yuyi
b10b65e134 cgen: fix error for interface with multi-nested embed struct (#13345) 2022-02-02 09:11:29 +02:00
Delyan Angelov
b2c299da48 vweb: support vweb.run_at(app, localhost, 8099) (#13337) 2022-02-01 18:41:12 +02:00
Delyan Angelov
d8cce0a71d ci: fix cgen for interface_struct_with_multi_nested_embed_test.v for gcc/clang 2022-02-01 17:12:15 +02:00
yuyi
a014844050 cgen: fix error for interface with multi nested embed structs (fix #13331) (#13336) 2022-02-01 14:50:12 +02:00
Tarcisio Gruppi
51513ae19a vfmt: keep file permissions with -w on !windows (#13334) 2022-02-01 14:49:06 +02:00
penguindark
7c1b249da0 regex: fix dot char problems on groups with * (#13333) 2022-02-01 13:49:37 +02:00
Delyan Angelov
310969a057 docs: clarify the interface methods section 2022-02-01 10:36:25 +02:00
Delyan Angelov
db50e79d26 tools: implement cgen tag for Markdown examples in v check-md (#13332) 2022-01-31 22:51:04 +02:00
4614 changed files with 421463 additions and 74551 deletions

View File

@@ -3,6 +3,7 @@ freebsd_instance:
freebsd_task:
name: Code CI / freebsd
skip: "!changesInclude('.cirrus.yml', '**.{v,vsh}')"
install_script: pkg install -y git
script: |
echo 'Building V'
@@ -13,76 +14,6 @@ freebsd_task:
##tcc -v -v
echo 'Build cmd/tools/fast'
cd cmd/tools/fast && ../../../v fast.v && ./fast -clang
arm64_task:
name: Code CI / arm64-ubuntu-tcc
arm_container:
image: ubuntu:latest
install_script: apt-get update -y && apt-get install --quiet -y build-essential pkg-config wget git valgrind libsqlite3-dev libssl-dev libxi-dev libxcursor-dev libfreetype6-dev libxi-dev libxcursor-dev libgl-dev xfonts-75dpi xfonts-base libmysqlclient-dev libpq-dev gcc-10-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user
env:
DEBIAN_FRONTEND: noninteractive
VFLAGS: -cc tcc -no-retry-compilation
VJOBS: 2
script: |
set -e
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_arm64.deb
apt install --fix-missing -y ./wkhtmltox_0.12.6-1.focal_arm64.deb
# ensure that a V binary can be built, even if tcc has broken for some reason
VFLAGS='-cc gcc' make
./v -g self
./v -g self
./v -d debug_malloc -d debug_realloc -o v cmd/v
./v -cg -cstrict -o v cmd/v
#Test v->c
thirdparty/tcc/tcc.exe -version
./v -cg -o v cmd/v # Make sure vtcc can build itself twice
# - name: v self compilation
./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
# - name: v self compilation with -skip-unused
./v -skip-unused -o v2 cmd/v && ./v2 -skip-unused -o v3 cmd/v && ./v3 -skip-unused -o v4 cmd/v
# - name: v doctor
./v doctor
# - name: Verify `v test` works
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
# - name: Self tests
./v -silent test-self
## - name: Self tests (-cstrict)
## ./v -cstrict test-self
# - name: Test time functions in a timezone UTC-12
TZ=Etc/GMT+12 ./v test vlib/time/
# - name: Test time functions in a timezone UTC-3
TZ=Etc/GMT+3 ./v test vlib/time/
# - name: Test time functions in a timezone UTC+3
TZ=Etc/GMT-3 ./v test vlib/time/
# - name: Test time functions in a timezone UTC+12
TZ=Etc/GMT-12 ./v test vlib/time/
# - name: Test time functions in a timezone using daylight saving (Europe/Paris)
TZ=Europe/Paris ./v test vlib/time/
# - name: Build examples
./v -W build-examples
# - name: Test building v tools
./v -W build-tools
# - name: Test v binaries
./v build-vbinaries
# - name: Run a VSH script
./v run examples/v_script.vsh
# - name: Test v tutorials
./v tutorials/building_a_simple_web_blog_with_vweb/code/blog
# test the arm32 version of tcc
# TODO: support something like `V_EMULATOR=qemu-arm v run file.v` so that V automatically runs all binaries under qemu
./v -arch arm32 -cc arm-linux-gnueabihf-gcc-10 -o av cmd/v && qemu-arm -L /usr/arm-linux-gnueabihf ./av -arch arm32 -cc arm-linux-gnueabihf-gcc-10 -o av2 cmd/v && qemu-arm -L /usr/arm-linux-gnueabihf ./av2 -arch arm32 -cc arm-linux-gnueabihf-gcc-10 -o av3 cmd/v && qemu-arm -L /usr/arm-linux-gnueabihf ./av3 -arch arm32 -cc arm-linux-gnueabihf-gcc-10 -o av4 cmd/v
./v -arch arm32 -o closure_test.c vlib/v/tests/closure_test.v && arm-linux-gnueabihf-gcc-10 -o closure_test closure_test.c && qemu-arm -L /usr/arm-linux-gnueabihf ./closure_test
echo 'Run test-self'
cd /tmp/cirrus-ci-build/v
VTEST_JUST_ESSENTIAL=1 ./v test-self

View File

@@ -8,7 +8,10 @@ trim_trailing_whitespace = true
[*.v]
indent_style = tab
indent_size = 4
[*.{bat,cmd}]
# BAT/CMD ~ DOS/Win requires BAT/CMD files to have CRLF EOLNs
end_of_line = crlf
[*.{yml,yaml}]
indent_style = space

2
.gitattributes vendored
View File

@@ -1,5 +1,7 @@
*.v linguist-language=V text=auto eol=lf
*.vv linguist-language=V text=auto eol=lf
*.vsh linguist-language=V text=auto eol=lf
**/v.mod linguist-language=V text=auto eol=lf
*.bat text=auto eol=crlf
Dockerfile.* linguist-language=Dockerfile
*.toml text eol=lf

View File

@@ -1,25 +0,0 @@
---
name: Bug report for V
about: Please use the appropriate label when submitting an issue: bug/feature request/question.
title: "New issue"
labels: ''
assignees: ''
---
<!-- You can use `v doctor` to fill up the next fields -->
#### V version:
#### OS:
#### C Compiler:
## What did you do?
### What did you expect to see?
### What did you see instead?

82
.github/ISSUE_TEMPLATE/bug-report.yml vendored Normal file
View File

@@ -0,0 +1,82 @@
name: 🐛 Bug Report
description: Report a bug
title: (bug report summary)
labels: Bug
body:
- type: textarea
id: description
attributes:
label: Describe the bug
description: What is the problem? A clear and concise description of the bug.
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected Behavior
description: What did you expect to happen?
validations:
required: true
- type: textarea
id: current
attributes:
label: Current Behavior
description: |
What actually happened?
Please include full errors, uncaught exceptions, stack traces, and relevant logs.
If service/functions responses are relevant, please include wire logs.
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Reproduction Steps
description: |
Provide a self-contained, concise snippet of code that can be used to reproduce the issue.
For more complex issues provide a repo with the smallest sample that reproduces the bug.
Avoid including business logic or unrelated code, it makes diagnosis more difficult.
The code sample should be an SSCCE. See http://sscce.org/ for details.
In short, please provide a code sample that we can copy/paste, run and reproduce.
validations:
required: true
- type: textarea
id: solution
attributes:
label: Possible Solution
description: Suggest a fix/reason for the bug
validations:
required: false
- type: textarea
id: context
attributes:
label: Additional Information/Context
description: |
Anything else that might be relevant for troubleshooting this bug.
Providing context helps us come up with a solution that is most useful in the real world.
validations:
required: false
- type: input
id: version
attributes:
label: V version
description: |
Please make sure to run `v up` before reporting any issues as it may have already been fixed.
It's also advisable to update all relevant modules using `v outdated` and `v install`.
validations:
required: true
- type: textarea
id: environment
attributes:
label: Environment details (OS name and version, etc.)
description: You can use `v doctor` to fill up this section.
validations:
required: true

View File

@@ -1,23 +0,0 @@
---
name: Bug report
about: Bug report
title: ''
labels: 'Bug'
assignees: ''
# When updating, make sure to update the template in 'cmd/tools/vbug.v' too
---
<!-- Please make sure to run `v up` before reporting any issues as it may have already been fixed.
It's also advisable to update all relevant modules using `v outdated` and `v install` -->
<!-- You can use `v doctor` to fill up the next fields -->
**V version:**
**OS:**
**What did you do?**
**What did you expect to see?**
**What did you see instead?**

9
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,9 @@
blank_issues_enabled: false
contact_links:
- name: 💬 General Questions and Answers about V
url: https://github.com/vlang/v/discussions/categories/questions-and-answers
about: You can ask and answer questions about V in the discussions forum.
- name: 💬 Discord Server
url: https://discord.gg/vlang
about: You can join our Discord server for real time discussion and support

View File

@@ -0,0 +1,20 @@
name: 📕 Documentation Issue
description: Report an issue in the Reference documentation or Developer Guide
title: (short issue description)
labels: "Unit: Documentation"
body:
- type: textarea
id: description
attributes:
label: Describe the issue
description: A clear and concise description of the issue.
validations:
required: true
- type: textarea
id: links
attributes:
label: Links
description: Include links to affected documentation page(s).
validations:
required: true

View File

@@ -0,0 +1,64 @@
name: 🚀 Feature Request
description: Suggest an idea for this project
title: (feature request summary)
labels: Feature Request
body:
- type: textarea
id: description
attributes:
label: Describe the feature
description: A clear and concise description of the feature you are proposing.
validations:
required: true
- type: textarea
id: use-case
attributes:
label: Use Case
description: |
Why do you need this feature? For example: "I'm always frustrated when..."
validations:
required: true
- type: textarea
id: solution
attributes:
label: Proposed Solution
description: Suggest how to implement the addition or change. Please include prototype/workaround/sketch/reference implementation.
validations:
required: false
- type: textarea
id: other
attributes:
label: Other Information
description: Any alternative solutions or features you considered, a more detailed explanation, stack traces, related issues, links for context, etc.
validations:
required: false
- type: checkboxes
id: ack
attributes:
label: Acknowledgements
options:
- label: I may be able to implement this feature request
required: false
- label: This feature might incur a breaking change
required: false
- type: input
id: version
attributes:
label: Version used
description: Please provide the version of the repository or tool you are using.
validations:
required: true
- type: textarea
id: environment
attributes:
label: Environment details (OS name and version, etc.)
description: You can use `v doctor` to fill up this section.
validations:
required: true

View File

@@ -1,10 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'Feature Request'
assignees: ''
---

View File

@@ -2,7 +2,7 @@
<!--
Please title your PR as follows: `time: fix foo bar`.
Please title your PR as follows: `module: description` (e.g. `time: fix date format`).
Always start with the thing you are fixing, then describe the fix.
Don't use past tense (e.g. "fixed foo bar").
@@ -33,3 +33,17 @@ Applying labels to PRs is not needed.
Thanks a lot for your contribution!
-->
<!--
ATTENTION! ⚠️
The below commands will be replaced with Copilot AI generated PR description.
This description will be automatically updated to describe the latest commit of this PR.
If you decided to remove them - please, provide a detailed description of your changes.
-->
copilot:summary
copilot:walkthrough

View File

@@ -15,6 +15,8 @@ ls -lat
## try running the known failing tests first to get faster feedback
./v test vlib/builtin/string_test.v vlib/strings/builder_test.v
./v test-cleancode
./v test-self
./v build-vbinaries

67
.github/workflows/android_cross_compile.vsh vendored Executable file
View File

@@ -0,0 +1,67 @@
#!/usr/bin/env -S v
module main
import os
import vab.vxt
import vab.android.ndk
fn main() {
assert ndk.found()
assert vxt.found()
work_dir := os.join_path(os.vtmp_dir(), 'android_cross_compile_test')
os.rm(work_dir) or {}
os.mkdir_all(work_dir) or { panic(err) }
vexe := vxt.vexe()
examples_dir := os.join_path(vxt.home(), 'examples')
v_example := os.join_path(examples_dir, 'toml.v')
ndk_version := ndk.default_version()
sysroot_path := ndk.sysroot_path(ndk_version) or { panic(err) }
include_path := os.join_path(sysroot_path, 'usr', 'include')
android_include_path := os.join_path(include_path, 'android')
//'-I"$include_path"'
cflags := ['-I"$android_include_path"', '-Wno-unused-value', '-Wno-implicit-function-declaration',
'-Wno-int-conversion']
for arch in ndk.supported_archs {
for level in ['min', 'max'] {
compiler_api := match level {
'min' {
ndk.compiler_min_api(.c, ndk_version, arch) or { panic(err) }
}
'max' {
ndk.compiler_max_api(.c, ndk_version, arch) or { panic(err) }
}
else {
panic('invalid min/max level')
}
}
os.setenv('VCROSS_COMPILER_NAME', compiler_api, true)
c_file := os.join_path(work_dir, arch + '-' + level + '.c')
o_file := os.join_path(work_dir, arch + '-' + level + '.o')
// x.v -> x.c
v_compile_cmd := '$vexe -o $c_file -os android -gc none $v_example'
vres := os.execute(v_compile_cmd)
if vres.exit_code != 0 {
panic('"$v_compile_cmd" failed: $vres.output')
}
assert os.exists(c_file)
// x.c -> x.o
compile_cmd := '$compiler_api ${cflags.join(' ')} -c $c_file -o $o_file'
cres := os.execute(compile_cmd)
if cres.exit_code != 0 {
panic('"$compile_cmd" failed: $cres.output')
}
assert os.exists(o_file)
compiler_exe_name := os.file_name(compiler_api)
println('Compiled examples/toml.v successfully for ($level) $arch $compiler_exe_name')
}
}
}

View File

@@ -1,23 +1,20 @@
name: Bootstraping works
on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
schedule:
- cron: '0 */6 * * *'
jobs:
ubuntu:
runs-on: ubuntu-20.04
timeout-minutes: 15
runs-on: ubuntu-latest
if: github.event.ref == 'refs/heads/master' && github.event.repository.full_name == 'vlang/v'
timeout-minutes: 30
env:
VFLAGS: -cc tcc -no-retry-compilation
B_CFLAGS: -g -std=gnu11 -I ./thirdparty/stdatomic/nix -w
B_CFLAGS: -g -std=c99 -w
B_LFLAGS: -lm -lpthread
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 10
- name: Build v
@@ -48,14 +45,15 @@ jobs:
./v2 -o v3 cmd/v
macos:
runs-on: macos-11
timeout-minutes: 15
runs-on: macos-latest
if: github.event.ref == 'refs/heads/master' && github.event.repository.full_name == 'vlang/v'
timeout-minutes: 30
env:
VFLAGS: -cc clang
B_CFLAGS: -g -std=gnu11 -I ./thirdparty/stdatomic/nix -w
B_CFLAGS: -g -std=c99 -w
B_LFLAGS: -lm -lpthread
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 10
- name: Build V

133
.github/workflows/c2v_ci.yml vendored Normal file
View File

@@ -0,0 +1,133 @@
name: C2V apps
on:
push:
paths-ignore:
- "**.md"
- "**.yml"
- "doc/**"
- "examples/**"
- "tutorials/**"
pull_request:
paths-ignore:
- "**.md"
- "**.yml"
- "doc/**"
- "examples/**"
- "tutorials/**"
concurrency:
group: build-c2v-apps-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
doom-compiles:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- name: Build V
run: make && ./v symlink -githubci
- name: Build C2V
run: |
echo "Clone C2V"
mkdir -p ~/code/
git clone --depth 1 https://github.com/vlang/c2v ~/code/c2v
ln -s ~/code/c2v ~/.vmodules/c2v
v -g ~/.vmodules/c2v/
~/.vmodules/c2v/c2v || true
- name: Install Doom Dependencies
run: |
sudo apt-get update -y -qq
sudo apt-get install libsdl2-dev libsdl2-mixer-dev libsdl2-net-dev libpng-dev libsamplerate0-dev
- name: Build original Chocolate Doom
run: |
git clone --quiet --depth 1 https://github.com/vlang/doom ~/code/doom
cd ~/code/doom/chocolate-doom
cmake -DCMAKE_BUILD_TYPE=Debug .
make chocolate-doom
- name: Translate the whole game in project/folder mode and compile it
run: |
cd ~/code/doom
touch ~/DOOM1.WAD
WAD_FILE=~/DOOM1.WAD ~/code/doom/build_whole_project.sh
doom-regressions:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 10
env:
VFLAGS: -cc tcc
DISPLAY: :99
LIBGL_ALWAYS_SOFTWARE: true
VTMP: /tmp
steps:
- uses: actions/checkout@v3
- name: Build V
run: make && ./v symlink -githubci
- name: Setup dependencies
run: |
sudo apt-get update -y -qq
# c2v / DOOM dependencies
sudo apt-get install libsdl2-dev libsdl2-mixer-dev libsdl2-net-dev libpng-dev libsamplerate0-dev
# vgret dependencies
# imagemagick : convert, mogrify, import
# xvfb : For starting X11 Virtual FrameBuffers
# openimageio-tools : idiff
# libgl1-mesa-dri : For headless rendering / software DRI driver (LIBGL_ALWAYS_SOFTWARE=true)
# freeglut3-dev : Fixes graphic apps compilation with tcc
sudo apt-get install imagemagick openimageio-tools freeglut3-dev libgl1-mesa-dri xvfb xsel xclip
# Fetch the free ~4MB DOOM1.WAD from the link at https://doomwiki.org/wiki/DOOM1.WAD
wget https://distro.ibiblio.org/slitaz/sources/packages/d/doom1.wad -O ~/doom1.wad
# Get imgur upload script
wget https://raw.githubusercontent.com/tremby/imgur.sh/c98345d/imgur.sh
chmod +x ./imgur.sh
# Get regression images to test against
git clone https://github.com/Larpon/doom-regression-images
- name: Build C2V
run: |
echo "Clone C2V"
mkdir -p ~/code/
git clone --depth 1 https://github.com/vlang/c2v ~/code/c2v
ln -s ~/code/c2v ~/.vmodules/c2v
v -g ~/.vmodules/c2v/
~/.vmodules/c2v/c2v || true
- name: Build original Chocolate Doom
run: |
git clone --quiet --depth 1 https://github.com/vlang/doom ~/code/doom
cd ~/code/doom/chocolate-doom
cmake -DCMAKE_BUILD_TYPE=Debug .
make chocolate-doom
- name: Translate the whole game in project/folder mode
run: |
cd ~/code/doom
WAD_FILE=~/doom1.wad ~/code/doom/build_whole_project.sh
- name: Sample and compare with vgret
id: compare
continue-on-error: true
run: |
Xvfb $DISPLAY -screen 0 800x600x24 -fbdir /var/tmp/ &
sleep 1; while [ ! -f /var/tmp/Xvfb_screen0 ]; do sleep 0.5; done # give xvfb time to start, even on slow CI runs
v gret -r ~/code/doom -t ./doom-regression-images/vgret.doom.toml -v ./doom-sample_images ./doom-regression-images
- name: Upload regression to imgur
if: steps.compare.outcome != 'success'
run: |
./imgur.sh /tmp/fail.png
./imgur.sh /tmp/diff.png
exit 1

View File

@@ -1,694 +0,0 @@
name: Code CI
on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
concurrency:
group: build-ci-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
ubuntu-tcc:
runs-on: ubuntu-20.04
timeout-minutes: 121
env:
VFLAGS: -cc tcc -no-retry-compilation
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
## The following is needed for examples/wkhtmltopdf.v
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
sudo apt-get install --quiet -y xfonts-75dpi xfonts-base
sudo dpkg -i wkhtmltox_0.12.6-1.focal_amd64.deb
- name: Build v
run: |
echo $VFLAGS
make
./v -d debug_malloc -d debug_realloc -o v cmd/v
./v -cg -cstrict -o v cmd/v
# Test v -realloc arena allocation
./v -o vrealloc -prealloc cmd/v && ./vrealloc -o v3 cmd/v && ./v3 -o v4 cmd/v
- name: Test v->c
run: |
thirdparty/tcc/tcc.exe -version
./v -cg -o v cmd/v # Make sure vtcc can build itself twice
# ./v -silent test-all
- name: v self compilation
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
- name: v self compilation with -skip-unused
run: ./v -skip-unused -o v2 cmd/v && ./v2 -skip-unused -o v3 cmd/v && ./v3 -skip-unused -o v4 cmd/v
- name: v doctor
run: |
./v doctor
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: Self tests
run: ./v -silent test-self
# - name: Self tests (-cstrict)
# run: ./v -cstrict test-self
- name: Test time functions in a timezone UTC-12
run: TZ=Etc/GMT+12 ./v test vlib/time/
- name: Test time functions in a timezone UTC-3
run: TZ=Etc/GMT+3 ./v test vlib/time/
- name: Test time functions in a timezone UTC+3
run: TZ=Etc/GMT-3 ./v test vlib/time/
- name: Test time functions in a timezone UTC+12
run: TZ=Etc/GMT-12 ./v test vlib/time/
- name: Test time functions in a timezone using daylight saving (Europe/Paris)
run: TZ=Europe/Paris ./v test vlib/time/
- name: Build examples
run: ./v -W build-examples
- name: Test building v tools
run: ./v -W build-tools
- name: Test v binaries
run: ./v build-vbinaries
- name: Run a VSH script
run: ./v run examples/v_script.vsh
- name: Test v tutorials
run: ./v tutorials/building_a_simple_web_blog_with_vweb/code/blog
- name: Build cmd/tools/fast
run: cd cmd/tools/fast && ../../../v fast.v && ./fast
- name: V self compilation with -usecache
run: |
unset VFLAGS
./v -usecache examples/hello_world.v && examples/hello_world
./v -o v2 -usecache cmd/v
./v2 -o v3 -usecache cmd/v
./v3 version
./v3 -o tetris -usecache examples/tetris/tetris.v
ubuntu-tcc-boehm-gc:
runs-on: ubuntu-20.04
timeout-minutes: 121
env:
VFLAGS: -cc tcc -no-retry-compilation
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install --quiet -y libgc-dev
## The following is needed for examples/wkhtmltopdf.v
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
sudo apt-get install --quiet -y xfonts-75dpi xfonts-base
sudo dpkg -i wkhtmltox_0.12.6-1.focal_amd64.deb
- name: Build v
run: |
echo $VFLAGS
make
- name: Test v->c
run: |
thirdparty/tcc/tcc.exe -version
./v -cg -o v cmd/v # Make sure vtcc can build itself twice
- name: v self compilation with -gc boehm
run: |
./v -gc boehm -o v2 cmd/v && ./v2 -gc boehm -o v3 cmd/v && ./v3 -gc boehm -o v4 cmd/v
mv v4 v
- name: v doctor
run: |
./v doctor
- name: Verify `v -gc boehm test` works
run: |
./v -gc boehm cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: Self tests with `-gc boehm` with V compiler using Boehm-GC itself
run: ./v -gc boehm -silent test-self
- name: Test leak detector
run: |
./v -gc boehm_leak -o testcase_leak vlib/v/tests/testcase_leak.vv
./testcase_leak 2>leaks.txt
grep "Found 1 leaked object" leaks.txt && grep ", sz=1000," leaks.txt
- name: Test leak detector not being active for `-gc boehm`
run: |
./v -gc boehm -o testcase_leak vlib/v/tests/testcase_leak.vv
./testcase_leak 2>leaks.txt
[ "$(stat -c %s leaks.txt)" = "0" ]
- name: Test leak detector not being active for normal compile
run: |
./v -o testcase_leak vlib/v/tests/testcase_leak.vv
./testcase_leak 2>leaks.txt
[ "$(stat -c %s leaks.txt)" = "0" ]
macos:
runs-on: macOS-latest
timeout-minutes: 121
env:
VFLAGS: -cc clang
PKG_CONFIG_PATH: /usr/local/opt/openssl@3/lib/pkgconfig
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: |
##brew install libpq openssl freetype ### these are *already installed* on Catalina ...
brew uninstall --ignore-dependencies libpq ## libpq is a dependency of PHP
brew install postgresql openssl
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
echo "PKG_CONFIG_PATH is '$PKG_CONFIG_PATH'"
- name: Build V
run: make -j4 && ./v -cg -cstrict -o v cmd/v
- name: Run sanitizers
run: |
./v -o v2 cmd/v -cflags -fsanitize=undefined
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v
- name: Build V using V
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v
- name: Test symlink
run: ./v symlink
# - name: Set up pg database
# run: |
# pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
# psql -d postgres -c 'select rolname from pg_roles'
# psql -d postgres -c 'create database customerdb;'
# psql -d customerdb -f examples/database/pg/mydb.sql
# - name: Test v->c
# run: ./v -silent test-all
# - name: Test v binaries
# run: ./v build-vbinaries
## - name: Test v->js
## run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: Self tests
run: VJOBS=1 ./v -silent test-self
- name: Build examples
run: ./v build-examples
- name: Build examples with -autofree
run: |
./v -autofree -o tetris examples/tetris/tetris.v
./v -autofree -o blog tutorials/building_a_simple_web_blog_with_vweb/code/blog
- name: v doctor
run: |
./v doctor
- name: Test ved
run: |
git clone --depth 1 https://github.com/vlang/ved
cd ved && ../v -o ved .
../v -autofree .
cd ..
# - name: Test c2v
# run: |
# git clone --depth 1 https://github.com/vlang/c2v
# cd c2v && ../v -o c2v .
# ../v .
# ../v run tests/run_tests.vsh
# ../v -experimental -w c2v_test.v
# cd ..
- name: Build V UI examples
run: |
git clone --depth 1 https://github.com/vlang/ui
cd ui
mkdir -p ~/.vmodules
ln -s $(pwd) ~/.vmodules/ui
../v examples/rectangles.v
## ../v run examples/build_examples.vsh
ubuntu:
runs-on: ubuntu-20.04
timeout-minutes: 121
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
- name: Build V
run: make -j4 && ./v -cc gcc -cg -cstrict -o v cmd/v
- name: Valgrind v.c
run: valgrind --error-exitcode=1 ./v -o v.c cmd/v
- name: Run sanitizers
run: |
./v -o v2 cmd/v -cflags -fsanitize=thread
./v -o v3 cmd/v -cflags "-fsanitize=undefined -fno-sanitize=alignment"
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v3 -o v.c cmd/v
# - name: Test V
# run: ./v -silent test-all
# - name: Test v binaries
# run: ./v build-vbinaries
## - name: Test v->js
## run: ./v -o hi.js examples/hello_v_js.v && node hi.js
# - name: Build Vorum
# run: git clone --depth 1 https://github.com/vlang/vorum && cd vorum && ../v . && cd ..
# - name: Build vpm
# run: git clone --depth 1 https://github.com/vlang/vpm && cd vpm && ../v . && cd ..
- name: Freestanding
run: ./v -freestanding run vlib/os/bare/bare_example_linux.v
- name: V self compilation
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
- name: V self compilation with -usecache
run: |
unset VFLAGS
./v -usecache examples/hello_world.v && examples/hello_world
./v -o v2 -usecache cmd/v
./v2 -o v3 -usecache cmd/v
./v3 version
./v3 -o tetris -usecache examples/tetris/tetris.v
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: Self tests
run: |
./v -silent test-self
- name: Self tests (-prod)
run: ./v -o vprod -prod cmd/v && ./vprod -silent test-self
- name: Self tests (-cstrict)
run: ./v -cc gcc -cstrict test-self
- name: Build examples
run: ./v build-examples
- name: Build tetris.v with -autofree
run: ./v -autofree -experimental -o tetris examples/tetris/tetris.v
- name: Build option_test.v with -autofree
run: ./v -autofree vlib/v/tests/option_test.v
- name: Build modules
run: |
./v build-module vlib/os
./v build-module vlib/builtin
./v build-module vlib/strconv
./v build-module vlib/time
./v build-module vlib/term
./v build-module vlib/math
./v build-module vlib/strings
./v build-module vlib/v/token
./v build-module vlib/v/ast
./v build-module vlib/v/parser
./v build-module vlib/v/gen/c
./v build-module vlib/v/depgraph
./v build-module vlib/os/cmdline
- name: native machine code generation
run: |
exit
./v -o vprod -prod cmd/v
cd cmd/tools
echo "Generating a 1m line V file..."
../../vprod gen1m.v
./gen1m > 1m.v
echo "Building it..."
../../vprod -backend native -o 1m 1m.v
echo "Running it..."
ls
# ./1m
# run: echo "TODO" #cd examples/native && ../../v -native hello_world.v && ./hello_world
# - name: Coveralls GitHub Action
# uses: coverallsapp/github-action@v1.0.1
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
ubuntu-clang:
runs-on: ubuntu-20.04
timeout-minutes: 121
env:
VFLAGS: -cc clang
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install --quiet -y clang
- name: Build V
run: make -j4 && ./v -cc clang -cg -cstrict -o v cmd/v
- name: Valgrind
run: valgrind --error-exitcode=1 ./v -o v.c cmd/v
- name: Run sanitizers
run: |
./v -o v2 cmd/v -cflags -fsanitize=memory
./v -o v3 cmd/v -cflags -fsanitize=thread
./v -o v4 cmd/v -cflags -fsanitize=undefined
./v -o v5 cmd/v -cflags -fsanitize=address,pointer-compare,pointer-subtract
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v3 -o v.c cmd/v
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v4 -o v.c cmd/v
ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v5 -o v.c cmd/v
- name: v self compilation
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
- name: v self compilation with -usecache
run: |
unset VFLAGS
./v -usecache examples/hello_world.v && examples/hello_world
./v -o v2 -usecache cmd/v
./v2 -o v3 -usecache cmd/v
./v3 version
./v3 -o tetris -usecache examples/tetris/tetris.v
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: Self tests
run: |
./v -silent test-self
- name: Self tests (-prod)
run: ./v -o vprod -prod cmd/v && ./vprod -silent test-self
- name: Self tests (-cstrict)
run: ./v -cstrict test-self
- name: Build examples
run: ./v build-examples
- name: Build examples with -autofree
run: |
./v -autofree -experimental -o tetris examples/tetris/tetris.v
- name: Build modules
run: |
./v build-module vlib/os
./v build-module vlib/builtin
./v build-module vlib/strconv
./v build-module vlib/time
./v build-module vlib/term
./v build-module vlib/math
./v build-module vlib/strings
./v build-module vlib/v/token
./v build-module vlib/v/ast
./v build-module vlib/v/parser
./v build-module vlib/v/gen/c
./v build-module vlib/v/depgraph
./v build-module vlib/os/cmdline
- name: native machine code generation
run: |
exit
./v -o vprod -prod cmd/v
cd cmd/tools
echo "Generating a 1m line V file..."
../../vprod gen1m.v
./gen1m > 1m.v
echo "Building it..."
../../vprod -backend native -o 1m 1m.v
echo "Running it..."
ls
windows-gcc:
runs-on: windows-2019
timeout-minutes: 121
env:
VFLAGS: -cc gcc
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Build
run: |
gcc --version
.\make.bat -gcc
- name: Test new v.c
run: .\v.exe -o v.c cmd/v && gcc -Werror -I ./thirdparty/stdatomic/win -municode -w v.c
- name: Install dependencies
run: |
.\v.exe setup-freetype
.\.github\workflows\windows-install-sqlite.bat
- name: v doctor
run: |
./v doctor
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: Self tests
run: |
.\v.exe -silent test-self
# - name: Test
# run: |
# .\v.exe -silent test-all
- name: Test v->js
run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test v binaries
run: ./v build-vbinaries
- name: Build examples
run: ./v build-examples
- name: v2 self compilation
run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v
windows-msvc:
runs-on: windows-2019
timeout-minutes: 121
env:
VFLAGS: -cc msvc
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Build
run: |
echo %VFLAGS%
echo $VFLAGS
.\make.bat -msvc
.\v.exe -cflags /WX self
- name: Install dependencies
run: |
.\v.exe setup-freetype
.\.github\workflows\windows-install-sqlite.bat
- name: v doctor
run: |
./v doctor
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: Self tests
run: |
./v -cg cmd\tools\vtest-self.v
./v -silent test-self
# - name: Test
# run: |
# .\v.exe -silent test-all
- name: Test v->js
run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test v binaries
run: ./v build-vbinaries
- name: Build examples
run: ./v build-examples
- name: v2 self compilation
run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v
windows-tcc:
runs-on: windows-2019
timeout-minutes: 121
env:
VFLAGS: -cc tcc -no-retry-compilation
VJOBS: 1
VTEST_SHOW_START: 1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Build with make.bat -tcc
run: |
.\make.bat -tcc
- name: Test new v.c
run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -I ./thirdparty/stdatomic/win -Werror -w -ladvapi32 -bt10 v.c
- name: Install dependencies
run: |
.\v.exe setup-freetype
.\.github\workflows\windows-install-sqlite.bat
- name: v doctor
run: |
./v doctor
- name: Verify `v test` works
run: |
.\v.exe cmd/tools/test_if_v_test_system_works.v
.\cmd\tools\test_if_v_test_system_works.exe
- name: Verify `v vlib/v/gen/c/coutput_test.v` works
run: |
.\v.exe vlib/v/gen/c/coutput_test.v
- name: Make sure running TCC64 instead of TCC32
run: ./v test .github\workflows\make_sure_ci_run_with_64bit_compiler_test.v
- name: Test ./v doc -v clipboard *BEFORE building tools*
run: ./v doc -v clipboard
- name: Test v build-tools
run: ./v -W build-tools
- name: Test ./v doc clipboard
run: ./v doc clipboard
- name: Self tests
run: ./v test-self
- name: Test v->js
run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test v binaries
run: ./v build-vbinaries
- name: Build examples
run: ./v build-examples
- name: v2 self compilation
run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v
## ## tcc32
## - name: Build with make.bat -tcc32
## run: |
## Remove-Item -Recurse -Force .\thirdparty\tcc
## .\v.exe wipe-cache
## .\make.bat -tcc32
## - name: Test new v.c
## run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -I ./thirdparty/stdatomic/win -Werror -g -w -ladvapi32 -bt10 v.c
## - name: v doctor
## run: ./v doctor
##
## - name: Verify `v test` works
## run: |
## .\v.exe cmd/tools/test_if_v_test_system_works.v
## .\cmd\tools\test_if_v_test_system_works.exe
##
## - name: Verify `v vlib/v/gen/c/coutput_test.v` works
## run: |
## .\v.exe vlib/v/gen/c/coutput_test.v
##
## - name: Make sure running TCC32 instead of TCC64
## run: ./v -stats .github\workflows\make_sure_ci_run_with_32bit_compiler_test.v
##
## - name: Test v build-tools
## run: ./v -W build-tools
##
## - name: Test ./v doc clipboard
## run: ./v doc clipboard
##
## - name: Self tests
## run: ./v test-self
## - name: Test v->js
## run: ./v -o hi.js examples/hello_v_js.v && node hi.js
## - name: Test v binaries
## run: ./v build-vbinaries
## - name: Build examples
## run: ./v build-examples
## - name: v2 self compilation
## run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v
alpine-docker-musl-gcc:
runs-on: ubuntu-20.04
timeout-minutes: 121
container:
# Alpine docker pre-built container
image: thevlang/vlang:alpine-build
env:
V_CI_MUSL: 1
VFLAGS: -cc gcc
volumes:
- ${{github.workspace}}:/opt/vlang
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Show Environment
run: |
echo "PWD:"
pwd
echo "ENVIRONMENT:"
env
echo "C Compiler:"
gcc --version
- name: Build V
run: CC=gcc make
- name: Test V fixed tests
run: ./v -silent test-self
# ubuntu-autofree-selfcompile:
# runs-on: ubuntu-20.04
# timeout-minutes: 121
# env:
# VFLAGS: -cc gcc
# steps:
# - uses: actions/checkout@v2
# - name: Build V
# run: make -j4
# - name: V self compilation with -autofree
# run: ./v -o v2 -autofree cmd/v && ./v2 -o v3 -autofree cmd/v && ./v3 -o v4 -autofree cmd/v
# ubuntu-musl:
# runs-on: ubuntu-20.04
# timeout-minutes: 121
# env:
# VFLAGS: -cc musl-gcc
# V_CI_MUSL: 1
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v1
# with:
# node-version: 12.x
# - name: Install dependencies
# run: |
# sudo apt-get install --quiet -y musl musl-tools libssl-dev sqlite3 libsqlite3-dev valgrind
# - name: Build v
# run: echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
# # - name: Test v binaries
# # run: ./v build-vbinaries
# ## - name: Test v->js
# ## run: ./v -o hi.js examples/hello_v_js.v && node hi.js
# - name: quick debug
# run: ./v -stats vlib/strconv/format_test.v
# - name: Self tests
# run: ./v -silent test-self
# Ubuntu docker pre-built container
ubuntu-musl:
runs-on: ubuntu-20.04
timeout-minutes: 121
container:
image: thevlang/vlang:ubuntu-build
env:
V_CI_MUSL: 1
V_CI_UBUNTU_MUSL: 1
VFLAGS: -cc musl-gcc
volumes:
- ${{github.workspace}}:/opt/vlang
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build V
run: |
echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: Test V fixed tests
run: |
./v -silent test-self

91
.github/workflows/containers_ci.yml vendored Normal file
View File

@@ -0,0 +1,91 @@
name: Containers CI
on:
push:
paths-ignore:
- "**.md"
- "**.yml"
pull_request:
paths-ignore:
- "**.md"
- "**.yml"
concurrency:
group: build-containers-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
alpine-docker-musl-gcc:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 181
container:
# Alpine docker pre-built container
image: thevlang/vlang:alpine-build
env:
V_CI_MUSL: 1
VFLAGS: -cc gcc
volumes:
- ${{github.workspace}}:/opt/vlang
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Show Environment
run: |
echo "PWD:"
pwd
echo "ENVIRONMENT:"
env
echo "C Compiler:"
gcc --version
## TODO: fix the container thevlang/vlang:alpine-build, instead of using apk add here:
- name: Add dependencies
run: |
apk add libexecinfo-static
apk add libexecinfo-dev
apk add libc6-compat
- name: Build V
run: CC=gcc make
- name: All code is formatted
run: ./v test-cleancode
- name: Run only essential tests
run: VTEST_JUST_ESSENTIAL=1 ./v test-self
ubuntu-docker-musl:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
container:
image: thevlang/vlang:ubuntu-build
env:
V_CI_MUSL: 1
V_CI_UBUNTU_MUSL: 1
VFLAGS: -cc musl-gcc -gc none
volumes:
- ${{github.workspace}}:/opt/vlang
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build V
run: |
echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Test V fixed tests
run: ./v test-self

View File

@@ -12,11 +12,12 @@ jobs:
macos-cross:
runs-on: macOS-latest
timeout-minutes: 15
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 25
env:
VFLAGS: -cc clang
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 10
@@ -41,18 +42,14 @@ jobs:
./v -os windows cmd/v
./v -os windows examples/2048/2048.v
- name: Compile to raw Android (non-graphic) compatible
run: |
# Test that V can compile non-graphic app to Android compatible code *without* using the -apk flag
./v -os android examples/toml.v
linux-cross:
runs-on: ubuntu-20.04
timeout-minutes: 15
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 25
env:
VFLAGS: -cc tcc -no-retry-compilation
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 10
- name: Install dependencies
@@ -62,6 +59,7 @@ jobs:
sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev
sudo apt-get install --quiet -y mingw-w64 wine-stable winetricks
## sudo apt-get install --quiet -y wine32
- name: Turn off the wine crash dialog
run: winetricks nocrashdialog
@@ -71,14 +69,14 @@ jobs:
- name: v.c can be compiled and run with -os cross
run: |
./v -os cross -o /tmp/v.c cmd/v
gcc -g -std=gnu11 -I ./thirdparty/stdatomic/nix -w -o v_from_vc /tmp/v.c -lm -lpthread
gcc -g -std=gnu11 -w -o v_from_vc /tmp/v.c -lm -lpthread
ls -lart v_from_vc
./v_from_vc version
- name: v_win.c can be compiled and run with -os windows
run: |
./v -os windows -o /tmp/v_win.c cmd/v
x86_64-w64-mingw32-gcc -I ./thirdparty/stdatomic/win /tmp/v_win.c -std=c99 -w -municode -o v_from_vc.exe
./v -cc msvc -os windows -o /tmp/v_win.c cmd/v
x86_64-w64-mingw32-gcc /tmp/v_win.c -std=c99 -w -municode -o v_from_vc.exe
ls -lart v_from_vc.exe
wine64 ./v_from_vc.exe version
@@ -93,19 +91,12 @@ jobs:
./v -os windows examples/2048/2048.v
ls -lart examples/2048/2048.exe
- name: toml.v can be compiled to raw Android C
run: |
# Test that V can compile non-graphic app to Android compatible code *without* using the -apk flag
./v -os android examples/toml.v
windows-cross:
runs-on: windows-2019
timeout-minutes: 15
env:
VFLAGS: -cc msvc
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 25
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build
run: |
echo %VFLAGS%
@@ -113,8 +104,8 @@ jobs:
.\make.bat -msvc
- name: TODO v_win.c can be compiled and run with -os windows
run: |
.\v.exe -os windows -showcc -o v2.exe cmd\v
.\v.exe -os windows -o v_win.c cmd\v
.\v.exe -os windows -cc msvc -showcc -o v2.exe cmd\v
.\v.exe -os windows -cc msvc -o v_win.c cmd\v
dir v2.exe
dir v_win.c
.\v2.exe version

View File

@@ -10,10 +10,10 @@ jobs:
env:
VFLAGS: -cc msvc
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 16
- name: Build
run: |
echo %VFLAGS%
@@ -25,16 +25,17 @@ jobs:
.\v.exe setup-freetype
.\.github\workflows\windows-install-sqlite.bat
- name: v doctor
run: |
./v doctor
run: ./v doctor
- name: Verify `v test` works
run: |
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests
run: |
./v -cg cmd\tools\vtest-self.v
./v -silent test-self
./v test-self
- name: Test v->js
run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test v binaries
@@ -43,4 +44,3 @@ jobs:
run: ./v build-examples
- name: v2 self compilation
run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v

View File

@@ -1,18 +1,47 @@
name: Docs CI
### Run on *EVERY* commit. The documentation *SHOULD* stay valid, and
### the developers should receive early warning if they break it.
on: [push, pull_request]
### Run on *EVERY* .v or .md related commit.
### The documentation *SHOULD* stay valid, and the developers should receive
### early warning, if they break it.
on:
push:
paths-ignore:
- "**.yml"
pull_request:
paths-ignore:
- "**.yml"
jobs:
check-markdown:
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build V
run: make
- name: Check markdown line length & code examples
run: ./v check-md -hide-warnings .
## NB: -hide-warnings is used here, so that the output is less noisy,
## thus real errors are easier to spot.
## NB: -hide-warnings is used here, so that the output is less noisy,
## thus real errors are easier to spot.
report-missing-fn-doc:
runs-on: ubuntu-20.04
timeout-minutes: 5
env:
MOPTIONS: --relative-paths --exclude /vlib/v/ --exclude /builtin/linux_bare/ --exclude /testdata/ --exclude /tests/
steps:
- uses: actions/checkout@v3
- name: Build V
run: make
- name: Checkout previous v
uses: actions/checkout@v3
with:
repository: vlang/v
ref: master # important
path: pv
- name: Check against parent commit
run: |
./v missdoc --diff $MOPTIONS pv/vlib vlib

View File

@@ -10,10 +10,11 @@ on:
jobs:
build-vc:
runs-on: ubuntu-latest
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
env:
VREPO: github.com/vlang/vc.git
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build V
run: make
- name: Regenerate v.c and v_win.c
@@ -31,7 +32,7 @@ jobs:
rm -rf vc/v.c vc/v_win.c
./v -o vc/v.c -os cross cmd/v
./v -o vc/v_win.c -os windows cmd/v
./v -o vc/v_win.c -os windows -cc msvc cmd/v
sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v.c
sed -i "1s/^/#define V_COMMIT_HASH \"$COMMIT_HASH\"\n/" vc/v_win.c

View File

@@ -10,44 +10,46 @@ on:
jobs:
gg-regressions:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 10
env:
VFLAGS: -cc tcc
DISPLAY: :99
LIBGL_ALWAYS_SOFTWARE: true
VTMP: /tmp
steps:
- name: Checkout V
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Build local v
run: make -j4
run: make
- name: Setup dependencies
run: |
# xvfb : xvfb (installed by openrndr/setup-opengl@v1.1)
# imagemagick : convert, mogrify
# xvfb : xvfb
# openimageio-tools : idiff
# libxcursor-dev libxi-dev : V gfx deps
# mesa-common-dev : For headless rendering
# libgl1-mesa-dri : For headless rendering / software DRI driver (LIBGL_ALWAYS_SOFTWARE=true)
# freeglut3-dev : Fixes graphic apps compilation with tcc
sudo apt-get install imagemagick openimageio-tools mesa-common-dev libxcursor-dev libxi-dev freeglut3-dev
sudo apt-get update
sudo apt-get install imagemagick openimageio-tools libgl1-mesa-dri xvfb libxcursor-dev libxi-dev freeglut3-dev xsel xclip
wget https://raw.githubusercontent.com/tremby/imgur.sh/c98345d/imgur.sh
git clone https://github.com/Larpon/gg-regression-images gg-regression-images
chmod +x ./imgur.sh
- uses: openrndr/setup-opengl@v1.1
- uses: actions/checkout@v2
with:
repository: Larpon/gg-regression-images
path: gg-regression-images
- name: Sample and compare
id: compare
continue-on-error: true
run: |
Xvfb $DISPLAY -screen 0 1280x1024x24 &
Xvfb $DISPLAY -screen 0 1280x1024x24 -fbdir /var/tmp/ &
sleep 1; while [ ! -f /var/tmp/Xvfb_screen0 ]; do sleep 0.5; done # give xvfb time to start, even on slow CI runs
./v gret -t ./gg-regression-images/vgret.v_examples.toml -v ./gg-sample_images ./gg-regression-images
- name: Upload regression to imgur
if: steps.compare.outcome != 'success'
run: |
./imgur.sh /tmp/fail.png
./imgur.sh /tmp/diff.png
exit 1

398
.github/workflows/linux_ci.yml vendored Normal file
View File

@@ -0,0 +1,398 @@
name: Code CI Linux
on:
push:
paths-ignore:
- "**.md"
- "**.yml"
pull_request:
paths-ignore:
- "**.md"
- "**.yml"
concurrency:
group: build-ci-linux-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
ubuntu-tcc:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc tcc -no-retry-compilation
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
## The following is needed for examples/wkhtmltopdf.v
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
sudo apt-get install --quiet -y xfonts-75dpi xfonts-base
sudo apt-get install --quiet -y expect
sudo dpkg -i wkhtmltox_0.12.6-1.focal_amd64.deb
- name: Build v
run: |
echo $VFLAGS
make
./v test-cleancode
./v -d debug_malloc -d debug_realloc -o v cmd/v
./v -cg -cstrict -o v cmd/v
# Test v -realloc arena allocation
./v -o vrealloc -prealloc cmd/v && ./vrealloc -o v3 cmd/v && ./v3 -o v4 cmd/v
- name: Test v->c
run: |
thirdparty/tcc/tcc.exe -version
./v -cg -o v cmd/v # Make sure vtcc can build itself twice
# ./v test-all
- name: v self compilation
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
- name: v self compilation with -skip-unused
run: ./v -skip-unused -o v2 cmd/v && ./v2 -skip-unused -o v3 cmd/v && ./v3 -skip-unused -o v4 cmd/v
- name: v doctor
run: |
./v doctor
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests
run: ./v test-self
# - name: Self tests (-cstrict)
# run: V_CI_CSTRICT=1 ./v -cstrict test-self
- name: Test time functions in a timezone UTC-12
run: TZ=Etc/GMT+12 ./v test vlib/time/
- name: Test time functions in a timezone UTC-3
run: TZ=Etc/GMT+3 ./v test vlib/time/
- name: Test time functions in a timezone UTC+3
run: TZ=Etc/GMT-3 ./v test vlib/time/
- name: Test time functions in a timezone UTC+12
run: TZ=Etc/GMT-12 ./v test vlib/time/
- name: Test time functions in a timezone using daylight saving (Europe/Paris)
run: TZ=Europe/Paris ./v test vlib/time/
- name: Build examples
run: ./v -W build-examples
- name: Test building v tools
run: ./v -W build-tools
- name: Test v binaries
run: ./v build-vbinaries
- name: Run a VSH script
run: ./v run examples/v_script.vsh
- name: Test v tutorials
run: ./v tutorials/building_a_simple_web_blog_with_vweb/code/blog
- name: Build cmd/tools/fast
run: cd cmd/tools/fast && ../../../v fast.v && ./fast
- name: V self compilation with -usecache
run: |
unset VFLAGS
./v -usecache examples/hello_world.v && examples/hello_world
./v -o v2 -usecache cmd/v
./v2 -o v3 -usecache cmd/v
./v3 version
./v3 -o tetris -usecache examples/tetris/tetris.v
- name: Test password input
run: |
./v examples/password
./v examples/password/password_ci.vsh
- name: Test readline
run: |
./v examples/readline/readline_ci.v
./v examples/readline/readline.vsh
ubuntu-tcc-boehm-gc:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc tcc -no-retry-compilation
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install --quiet -y libgc-dev
## The following is needed for examples/wkhtmltopdf.v
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
sudo apt-get install --quiet -y xfonts-75dpi xfonts-base
sudo dpkg -i wkhtmltox_0.12.6-1.focal_amd64.deb
- name: Build v
run: |
echo $VFLAGS
make
- name: Test v->c
run: |
thirdparty/tcc/tcc.exe -version
./v -cg -o v cmd/v # Make sure vtcc can build itself twice
- name: v self compilation with -gc boehm
run: |
./v -gc boehm -o v2 cmd/v && ./v2 -gc boehm -o v3 cmd/v && ./v3 -gc boehm -o v4 cmd/v
mv v4 v
- name: v doctor
run: |
./v doctor
- name: Verify `v -gc boehm test` works
run: |
./v -gc boehm cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests with `-gc boehm` with V compiler using Boehm-GC itself
run: ./v -gc boehm test-self
- name: Test leak detector
run: |
./v -gc boehm_leak -o testcase_leak vlib/v/tests/testcase_leak.vv
./testcase_leak 2>leaks.txt
grep "Found 1 leaked object" leaks.txt && grep -P ", sz=\s?1000," leaks.txt
- name: Test leak detector not being active for `-gc boehm`
run: |
./v -gc boehm -o testcase_leak vlib/v/tests/testcase_leak.vv
./testcase_leak 2>leaks.txt
[ "$(stat -c %s leaks.txt)" = "0" ]
- name: Test leak detector not being active for normal compile
run: |
./v -o testcase_leak vlib/v/tests/testcase_leak.vv
./testcase_leak 2>leaks.txt
[ "$(stat -c %s leaks.txt)" = "0" ]
ubuntu:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
- name: Build V
run: make -j4 && ./v -cc gcc -cg -cstrict -o v cmd/v
- name: Valgrind v.c
run: valgrind --error-exitcode=1 ./v -o v.c cmd/v
- name: Run sanitizers
run: |
./v -o v2 cmd/v -cflags -fsanitize=thread
./v -o v3 cmd/v -cflags "-fsanitize=undefined -fno-sanitize=alignment"
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v3 -o v.c cmd/v
# - name: Test V
# run: ./v test-all
# - name: Test v binaries
# run: ./v build-vbinaries
## - name: Test v->js
## run: ./v -o hi.js examples/hello_v_js.v && node hi.js
# - name: Build Vorum
# run: git clone --depth 1 https://github.com/vlang/vorum && cd vorum && ../v . && cd ..
- name: Build vpm
run: git clone --depth 1 https://github.com/vlang/vpm && cd vpm && ../v . || ../v cmd/vpm && cd ..
- name: Freestanding
run: ./v -freestanding run vlib/os/bare/bare_example_linux.v
- name: V self compilation
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
- name: V self compilation with -usecache
run: |
unset VFLAGS
./v -usecache examples/hello_world.v && examples/hello_world
./v -o v2 -usecache cmd/v
./v2 -o v3 -usecache cmd/v
./v3 version
./v3 -o tetris -usecache examples/tetris/tetris.v
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests
run: ./v test-self
- name: Self tests (-prod)
run: ./v -o vprod -prod cmd/v && ./vprod test-self
- name: Self tests (-cstrict)
run: VTEST_JUST_ESSENTIAL=1 V_CI_CSTRICT=1 ./v -cc gcc -cstrict test-self
- name: Build examples
run: ./v build-examples
- name: Build tetris.v with -autofree
run: ./v -autofree -experimental -o tetris examples/tetris/tetris.v
- name: Build option_test.v with -autofree
run: ./v -autofree vlib/v/tests/option_test.v
- name: V self compilation with -parallel-cc
run: |
./v -o v2 -parallel-cc cmd/v
- name: Build modules
run: |
./v build-module vlib/os
./v build-module vlib/builtin
./v build-module vlib/strconv
./v build-module vlib/time
./v build-module vlib/term
./v build-module vlib/math
./v build-module vlib/strings
./v build-module vlib/v/token
./v build-module vlib/v/ast
./v build-module vlib/v/parser
./v build-module vlib/v/gen/c
./v build-module vlib/v/depgraph
./v build-module vlib/os/cmdline
- name: native machine code generation
run: |
exit
./v -o vprod -prod cmd/v
cd cmd/tools
echo "Generating a 1m line V file..."
../../vprod gen1m.v
./gen1m > 1m.v
echo "Building it..."
../../vprod -backend native -o 1m 1m.v
echo "Running it..."
ls
# ./1m
# run: echo "TODO" #cd examples/native && ../../v -native hello_world.v && ./hello_world
# - name: Coveralls GitHub Action
# uses: coverallsapp/github-action@v1.0.1
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
ubuntu-clang:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc clang
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install --quiet -y clang
- name: Build V
run: make -j4 && ./v -cc clang -cg -cstrict -o v cmd/v
- name: Valgrind
run: valgrind --error-exitcode=1 ./v -o v.c cmd/v
- name: Run sanitizers
run: |
./v -o v2 cmd/v -cflags -fsanitize=memory
./v -o v3 cmd/v -cflags -fsanitize=thread
./v -o v4 cmd/v -cflags -fsanitize=undefined
./v -o v5 cmd/v -cflags -fsanitize=address,pointer-compare,pointer-subtract
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v3 -o v.c cmd/v
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v4 -o v.c cmd/v
ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v5 -o v.c cmd/v
- name: v self compilation
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v
- name: v self compilation with -usecache
run: |
unset VFLAGS
./v -usecache examples/hello_world.v && examples/hello_world
./v -o v2 -usecache cmd/v
./v2 -o v3 -usecache cmd/v
./v3 version
./v3 -o tetris -usecache examples/tetris/tetris.v
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests
run: ./v test-self
- name: Self tests (vprod)
run: |
./v -o vprod -prod cmd/v
./vprod test-self
- name: Self tests (-cstrict)
run: VTEST_JUST_ESSENTIAL=1 V_CI_CSTRICT=1 ./vprod -cstrict test-self
- name: Build examples
run: ./v build-examples
- name: Build examples with -autofree
run: |
./v -autofree -experimental -o tetris examples/tetris/tetris.v
- name: Build modules
run: |
./v build-module vlib/os
./v build-module vlib/builtin
./v build-module vlib/strconv
./v build-module vlib/time
./v build-module vlib/term
./v build-module vlib/math
./v build-module vlib/strings
./v build-module vlib/v/token
./v build-module vlib/v/ast
./v build-module vlib/v/parser
./v build-module vlib/v/gen/c
./v build-module vlib/v/depgraph
./v build-module vlib/os/cmdline
- name: native machine code generation
run: |
exit
./v -o vprod -prod cmd/v
cd cmd/tools
echo "Generating a 1m line V file..."
../../vprod gen1m.v
./gen1m > 1m.v
echo "Building it..."
../../vprod -backend native -o 1m 1m.v
echo "Running it..."
ls
# ubuntu-autofree-selfcompile:
# runs-on: ubuntu-20.04
# if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
# timeout-minutes: 121
# env:
# VFLAGS: -cc gcc
# steps:
# - uses: actions/checkout@v3
# - name: Build V
# run: make -j4
# - name: V self compilation with -autofree
# run: ./v -o v2 -autofree cmd/v && ./v2 -o v3 -autofree cmd/v && ./v3 -o v4 -autofree cmd/v
# ubuntu-musl:
# runs-on: ubuntu-20.04
# if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
# timeout-minutes: 121
# env:
# VFLAGS: -cc musl-gcc
# V_CI_MUSL: 1
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: 16
# - name: Install dependencies
# run: |
# sudo apt-get install --quiet -y musl musl-tools libssl-dev sqlite3 libsqlite3-dev valgrind
# - name: Build v
# run: echo $VFLAGS && make -j4 && ./v -cg -o v cmd/v
# # - name: Test v binaries
# # run: ./v build-vbinaries
# ## - name: Test v->js
# ## run: ./v -o hi.js examples/hello_v_js.v && node hi.js
# - name: quick debug
# run: ./v -stats vlib/strconv/format_test.v
# - name: Self tests
# run: ./v test-self

122
.github/workflows/macos_ci.yml vendored Normal file
View File

@@ -0,0 +1,122 @@
name: Code CI macos
on:
push:
paths-ignore:
- "**.md"
- "**.yml"
pull_request:
paths-ignore:
- "**.md"
- "**.yml"
concurrency:
group: build-ci-macos-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
macos:
runs-on: macOS-12
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc clang
PKG_CONFIG_PATH: /usr/local/opt/pkgconfig:/usr/local/opt/libpq/lib/pkgconfig:/usr/local/opt/openssl@3/lib/pkgconfig:/opt/homebrew/lib/pkgconfig:/opt/homebrew/opt/libpq/lib/pkgconfig:/opt/homebrew/opt/openssl@3/lib/pkgconfig
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: |
echo "PKG_CONFIG_PATH is '$PKG_CONFIG_PATH'"
brew install libpq openssl
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
echo "LIBRARY_PATH is '$LIBRARY_PATH'"
- name: Build V
run: make -j4 && ./v -cg -cstrict -o v cmd/v
- name: Run sanitizers
run: |
./v -o v2 cmd/v -cflags -fsanitize=undefined
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v
- name: Build V using V
run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v
- name: Test symlink
run: ./v symlink
- name: Build vpm
run: git clone --depth 1 https://github.com/vlang/vpm && cd vpm && ../v . || ../v cmd/vpm && cd ..
# - name: Set up pg database
# run: |
# pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
# psql -d postgres -c 'select rolname from pg_roles'
# psql -d postgres -c 'create database customerdb;'
# psql -d customerdb -f examples/database/pg/mydb.sql
# - name: Test v->c
# run: ./v test-all
# - name: Test v binaries
# run: ./v build-vbinaries
## - name: Test v->js
## run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: VJOBS=1 ./v test-cleancode
- name: Self tests
run: VJOBS=1 ./v test-self
- name: Build examples
run: ./v build-examples
- name: Build examples with -autofree
run: |
./v -autofree -o tetris examples/tetris/tetris.v
./v -autofree -o blog tutorials/building_a_simple_web_blog_with_vweb/code/blog
- name: Build examples with -prod
run: |
./v -prod examples/news_fetcher.v
- name: v doctor
run: |
./v doctor
- name: Test ved
run: |
git clone --depth 1 https://github.com/vlang/ved
cd ved && ../v -o ved .
../v -autofree .
../v -prod .
cd ..
# - name: Test c2v
# run: |
# git clone --depth 1 https://github.com/vlang/c2v
# cd c2v && ../v -o c2v .
# ../v .
# ../v run tests/run_tests.vsh
# ../v -experimental -w c2v_test.v
# cd ..
- name: Build V UI examples
run: |
git clone --depth 1 https://github.com/vlang/ui
cd ui
mkdir -p ~/.vmodules
ln -s $(pwd) ~/.vmodules/ui
../v examples/rectangles.v
## ../v run examples/build_examples.vsh
- name: V self compilation with -usecache
run: |
unset VFLAGS
./v -usecache examples/hello_world.v && examples/hello_world
./v -o v2 -usecache cmd/v
./v2 -o v3 -usecache cmd/v
./v3 version
./v3 -o tetris -usecache examples/tetris/tetris.v
- name: V self compilation with -parallel-cc
run: |
./v -o v2 -parallel-cc cmd/v
- name: Test password input
run: |
./v examples/password
./v examples/password/password_ci.vsh
- name: Test readline
run: |
./v examples/readline/readline_ci.v
./v examples/readline/readline.vsh

View File

@@ -1,5 +1,7 @@
fn test_ci_run_with_32bit_compiler() {
$if x64 {
assert false
}
}
fn test_ci_run_with_32bit_compiler() {
$if x64 && tinyc {
// TODO: uncomment that next assert when tcc32 vs tcc64 detection on windows works reliably
// assert false
assert true
}
}

View File

@@ -10,7 +10,7 @@ jobs:
build-module-docs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build V
run: make
- name: Build module documentation

View File

@@ -0,0 +1,79 @@
name: native backend CI
on:
push:
paths:
- '!**'
- '!**.md'
- 'vlib/v/gen/native/'
- 'cmd/tools/builders/**.v'
- 'vlib/builtin/**.v'
- 'vlib/v/ast/**.v'
- 'vlib/v/scanner/**.v'
- 'vlib/v/parser/**.v'
- 'vlib/v/checker/**.v'
- 'vlib/v/gen/c/**.v'
- 'vlib/v/builder/**.v'
- 'vlib/v/cflag/**.v'
- 'vlib/v/live/**.v'
- 'vlib/v/util/**.v'
- 'vlib/v/markused/**.v'
- 'vlib/v/preludes/**.v'
- 'vlib/v/gen/native/**.v'
- 'vlib/v/gen/native/tests/**.v'
pull_request:
paths:
- '!**'
- '!**.md'
- 'vlib/v/gen/native/'
- 'cmd/tools/builders/**.v'
- 'vlib/builtin/**.v'
- 'vlib/v/ast/**.v'
- 'vlib/v/scanner/**.v'
- 'vlib/v/parser/**.v'
- 'vlib/v/checker/**.v'
- 'vlib/v/gen/c/**.v'
- 'vlib/v/builder/**.v'
- 'vlib/v/cflag/**.v'
- 'vlib/v/live/**.v'
- 'vlib/v/util/**.v'
- 'vlib/v/markused/**.v'
- 'vlib/v/preludes/**.v'
- 'vlib/v/gen/native/**.v'
- 'vlib/v/gen/native/tests/**.v'
concurrency:
group: native-backend-ci-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
native-backend:
strategy:
matrix:
os: [
ubuntu-20.04,
macos-11, macos-12,
windows-2019, windows-2022
]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install linker
if: ${{ startsWith(matrix.os, 'ubuntu')}}
run: |
sudo apt-get install --quiet -y binutils
- name: Build V with make.bat
if: ${{ startsWith(matrix.os, 'windows') }}
run: |
.\make.bat
.\v.exe symlink -githubci
- name: Build V with make
if: ${{ !startsWith(matrix.os, 'windows') }}
run: |
make
./v symlink -githubci
- name: Test the native backend
run: v test vlib/v/gen/native/

View File

@@ -15,36 +15,39 @@ concurrency:
jobs:
no-gpl-by-accident:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: No GPL licensed code, should be added accidentally
run: |
! grep -r --exclude="*.yml" "a GPL license" .
code-formatting:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 15
env:
VFLAGS: -cc gcc
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Environment info
run: echo $VFLAGS $GITHUB_SHA $GITHUB_REF
- name: Build local v
run: make -j4
- name: v test-cleancode
run: ./v -silent test-cleancode
run: ./v test-cleancode
- name: v test-fmt
run: ./v -silent test-fmt
run: ./v test-fmt
performance-regressions:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 15
env:
VFLAGS: -cc gcc
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Environment info
run: echo $VFLAGS $GITHUB_SHA $GITHUB_REF
- name: Build local v
@@ -60,26 +63,39 @@ jobs:
- name: Repeat -o hw.c examples/hello_world.v
run: cmd/tools/repeat --max_time 251 --series 3 --count 20 --nmins 2 --nmaxs 5 --warmup 3 --fail_percent 10 -t 'cd {T} ; ./v -show-timings -o hw.c examples/hello_world.v' . ./vmaster
- name: Repeat -o v.c cmd/v
run: cmd/tools/repeat --max_time 1501 --series 3 --count 20 --nmins 2 --nmaxs 5 --warmup 3 --fail_percent 10 -t 'cd {T} ; ./v -show-timings -o v.c cmd/v' . ./vmaster
run: cmd/tools/repeat --max_time 1701 --series 3 --count 20 --nmins 2 --nmaxs 5 --warmup 3 --fail_percent 10 -t 'cd {T} ; ./v -show-timings -o v.c cmd/v' . ./vmaster
misc-tooling:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc tcc -no-retry-compilation
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 10
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install --quiet -y xfonts-75dpi xfonts-base
sudo apt-get install --quiet -y libsodium-dev libssl-dev sqlite3 libsqlite3-dev postgresql libpq-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev xfonts-75dpi xfonts-base
sudo apt-get install --quiet -y g++-9 g++-11
- name: Build v
run: make
- name: g++-9 version
run: g++-9 --version
- name: V self compilation with g++ and -std=c++11
run: ./v -cc g++-9 -no-std -cflags -std=c++11 -o v2 cmd/v && ./v2 -cc g++-9 -no-std -cflags -std=c++11 -o v3 cmd/v
- name: g++-11 version
run: g++-11 --version
- name: V self compilation with g++ and -std=c++20
run: ./v -cc g++-11 -no-std -cflags -std=c++20 -o v2 cmd/v && ./v2 -cc g++-11 -no-std -cflags -std=c++20 -o v3 cmd/v
- name: Ensure V can be compiled with -autofree
run: ./v -autofree -o v2 cmd/v ## NB: this does not mean it runs, but at least keeps it from regressing
@@ -97,28 +113,14 @@ jobs:
echo "compiling shader $f.glsl ..."; \
./sokol-shdc --input $f.glsl --output $f.h --slang glsl330 ; \
done
for vfile in examples/sokol/0?*/*.v; do echo "compiling $vfile ..."; ./v $vfile ; done
- name: Install C++ dependencies
run: |
sudo apt-get install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install --quiet -y valgrind g++-9
- name: Build V
run: make -j4
- name: g++ version
run: g++-9 --version
- name: V self compilation with g++
run: ./v -cc g++-9 -no-std -cflags -std=c++11 -o v2 cmd/v && ./v2 -cc g++-9 -no-std -cflags -std=c++11 -o v3 cmd/v
## - name: Running tests with g++
## run: ./v -cc g++-9 -silent test-self
./v should-compile-all examples/sokol/*.v examples/sokol/0?*/*.v
parser-silent:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install zzuf
run: sudo apt install -qq zzuf
- name: Build local v
@@ -151,98 +153,3 @@ jobs:
./v test-parser -S examples/cli_fuzz.v
./v test-parser -S examples/regex_example_fuzz.v
./v test-parser -S examples/2048/2048_fuzz.v
v-apps-compile:
runs-on: ubuntu-20.04
timeout-minutes: 121
steps:
- uses: actions/checkout@v2
- name: Build V
run: make && sudo ./v symlink
- name: Install dependencies
run: sudo apt-get install --quiet -y libgc-dev
## vls
- name: Clone VLS
run: git clone --depth 1 https://github.com/vlang/vls
- name: Build VLS
run: pushd vls; v cmd/vls ; popd
- name: Build VLS with -prod
run: pushd vls; v -prod cmd/vls; popd
- name: Build VLS with -gc boehm -skip-unused
run: pushd vls; v -gc boehm -skip-unused cmd/vls; popd
## vsl
- name: Clone VSL
run: git clone --depth 1 https://github.com/vlang/vsl ~/.vmodules/vsl
- name: Install dependencies
run: sudo apt-get install --quiet -y --no-install-recommends gfortran liblapacke-dev libopenblas-dev libgc-dev
- name: Execute Tests using Pure V Backend
run: ~/.vmodules/vsl/bin/test
- name: Execute Tests using Pure V Backend with Pure V Math
run: ~/.vmodules/vsl/bin/test --use-cblas
- name: Execute Tests using Pure V Backend and Garbage Collection enabled
run: ~/.vmodules/vsl/bin/test --use-gc boehm
- name: Execute Tests using Pure V Backend with Pure V Math and Garbage Collection enabled
run: ~/.vmodules/vsl/bin/test --use-cblas --use-gc boehm
## vtl
- name: Clone VTL
run: git clone --depth 1 https://github.com/vlang/vtl ~/.vmodules/vtl
- name: Install dependencies
run: sudo apt-get install --quiet -y --no-install-recommends gfortran liblapacke-dev libopenblas-dev libgc-dev
- name: Execute Tests using Pure V Backend
run: ~/.vmodules/vtl/bin/test
- name: Execute Tests using Pure V Backend with Pure V Math
run: ~/.vmodules/vtl/bin/test --use-cblas
- name: Execute Tests using Pure V Backend and Garbage Collection enabled
run: ~/.vmodules/vtl/bin/test --use-gc boehm
- name: Execute Tests using Pure V Backend with Pure V Math and Garbage Collection enabled
run: ~/.vmodules/vtl/bin/test --use-cblas --use-gc boehm
## vab
- name: Clone vab
run: git clone --depth 1 https://github.com/vlang/vab
- name: Build vab
run: cd vab; ../v ./vab.v ; cd ..
- name: Build vab with -gc boehm -skip-unused
run: cd vab; ../v -gc boehm -skip-unused ./vab.v ; cd ..
## gitly
- name: Install markdown
run: ./v install markdown
- name: Build Gitly
run: |
git clone --depth 1 https://github.com/vlang/gitly
cd gitly
../v .
# ./gitly -ci_run
../v -autofree .
../v -o x tests/first_run.v
./x
cd ..
## vex
- name: Install Vex dependencies
run: sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev
- name: Install Vex
run: mkdir -p ~/.vmodules/nedpals; git clone https://github.com/nedpals/vex ~/.vmodules/nedpals/vex
- name: Compile the simple Vex example
run: ./v ~/.vmodules/nedpals/vex/examples/simple_example.v
- name: Compile the simple Vex example with -gc boehm -skip-unused
run: ./v -gc boehm -skip-unused ~/.vmodules/nedpals/vex/examples/simple_example.v
- name: Run Vex Tests
run: ./v test ~/.vmodules/nedpals/vex
## vpm modules
- name: Install UI through VPM
run: ./v install ui
## libsodium
- name: Install libsodium-dev package
run: sudo apt-get install --quiet -y libsodium-dev
- name: Installl the libsodium wrapper through VPM
run: ./v install libsodium
- name: Test libsodium
run: ./v test ~/.vmodules/libsodium

View File

@@ -16,11 +16,12 @@ jobs:
space-paths-linux:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 30
env:
MY_V_PATH: '你好 my $path, @с интервали'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
path: ${{env.MY_V_PATH}}
- name: Build V
@@ -41,11 +42,12 @@ jobs:
space-paths-macos:
runs-on: macOS-latest
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 30
env:
MY_V_PATH: '你好 my $path, @с интервали'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
path: ${{env.MY_V_PATH}}
- name: Build V
@@ -69,6 +71,7 @@ jobs:
space-paths-windows:
runs-on: windows-2022
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 30
env:
MY_V_PATH: 'path with some $punctuation, and some spaces'
@@ -84,7 +87,7 @@ jobs:
## and that happens even for gcc builds, not just tcc ones
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
path: ${{env.MY_V_PATH}}
- name: Build V

View File

@@ -1,58 +0,0 @@
name: Periodic
on:
schedule:
- cron: '0 */2 * * *'
jobs:
network-tests-ubuntu:
runs-on: ubuntu-20.04
timeout-minutes: 30
env:
V_CI_PERIODIC: 1
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind
- name: Build v
run: make -j4
- name: Symlink V
run: sudo ./v symlink
## - name: Run network tests
## run: ./v -d network test vlib/net
network-tests-macos:
runs-on: macOS-latest
timeout-minutes: 30
env:
V_CI_PERIODIC: 1
steps:
- uses: actions/checkout@v2
- name: Setup openssl library path
run: export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
- name: Build V
run: make -j4
- name: Symlink V
run: sudo ./v symlink
- name: Ensure thirdparty/cJSON/cJSON.o is compiled, before running tests.
run: ./v examples/json.v
## - name: Run network tests
## run: ./v -d network test vlib/net
network-windows-msvc:
runs-on: windows-2019
timeout-minutes: 30
env:
V_CI_PERIODIC: 1
VFLAGS: -cc msvc
steps:
- uses: actions/checkout@v2
- name: Build
run: |
echo %VFLAGS%
echo $VFLAGS
.\make.bat -msvc
## - name: Run network tests
## run: .\v.exe -d network test vlib/net

60
.github/workflows/periodic_ci.yml vendored Normal file
View File

@@ -0,0 +1,60 @@
name: Periodic
on:
schedule:
- cron: '0 */6 * * *'
jobs:
network-tests-ubuntu:
runs-on: ubuntu-20.04
if: github.event.ref == 'refs/heads/master' && github.event.repository.full_name == 'vlang/v'
timeout-minutes: 30
env:
V_CI_PERIODIC: 1
steps:
- uses: actions/checkout@v3
- name: Install dependencies 1
run: sudo apt-get install --quiet -y libssl-dev sqlite3 libsqlite3-dev
- name: Build v
run: make
- name: Symlink V
run: sudo ./v symlink
## - name: Run network tests
## run: ./v -d network test vlib/net
network-tests-macos:
runs-on: macOS-latest
if: github.event.ref == 'refs/heads/master' && github.event.repository.full_name == 'vlang/v'
timeout-minutes: 30
env:
V_CI_PERIODIC: 1
steps:
- uses: actions/checkout@v3
- name: Setup openssl library path
run: export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/opt/openssl/lib/"
- name: Build V
run: make
- name: Symlink V
run: sudo ./v symlink
- name: Ensure thirdparty/cJSON/cJSON.o is compiled, before running tests.
run: ./v examples/json.v
## - name: Run network tests
## run: ./v -d network test vlib/net
network-windows-msvc:
runs-on: windows-2019
if: github.event.ref == 'refs/heads/master' && github.event.repository.full_name == 'vlang/v'
timeout-minutes: 30
env:
V_CI_PERIODIC: 1
VFLAGS: -cc msvc
steps:
- uses: actions/checkout@v3
- name: Build
run: |
echo %VFLAGS%
echo $VFLAGS
.\make.bat -msvc
## - name: Run network tests
## run: .\v.exe -d network test vlib/net

View File

@@ -15,10 +15,17 @@ on:
push:
paths:
- '!**'
- '!**.md'
- '!**.yml'
- 'cmd/tools/vtest*'
- 'cmd/tools/builders/**.v'
- 'vlib/builtin/**.v'
- 'vlib/strconv/**.v'
- 'vlib/strings/**.v'
- 'vlib/math/**.v'
- 'vlib/math/big/**.v'
- 'vlib/arrays/**.v'
- 'vlib/datatypes/**.v'
- 'vlib/os/**.v'
- 'vlib/sync/**.v'
- 'vlib/v/tests/**.v'
@@ -27,18 +34,25 @@ on:
- 'vlib/v/parser/**.v'
- 'vlib/v/checker/**.v'
- 'vlib/v/gen/c/**.v'
- 'vlib/v/builder/**.v'
- 'vlib/v/cflag/**.v'
- 'vlib/v/live/**.v'
- 'vlib/v/util/**.v'
- 'vlib/v/markused/**.v'
- 'vlib/v/preludes/**.v'
- 'vlib/v/embed_file/**.v'
pull_request:
paths:
- '!**'
- 'cmd/tools/vtest*'
- 'cmd/tools/builders/**.v'
- 'vlib/builtin/**.v'
- 'vlib/strconv/**.v'
- 'vlib/strings/**.v'
- 'vlib/math/**.v'
- 'vlib/math/big/**.v'
- 'vlib/arrays/**.v'
- 'vlib/datatypes/**.v'
- 'vlib/os/**.v'
- 'vlib/sync/**.v'
- 'vlib/v/tests/**.v'
@@ -47,9 +61,11 @@ on:
- 'vlib/v/parser/**.v'
- 'vlib/v/checker/**.v'
- 'vlib/v/gen/c/**.v'
- 'vlib/v/builder/**.v'
- 'vlib/v/cflag/**.v'
- 'vlib/v/live/**.v'
- 'vlib/v/util/**.v'
- 'vlib/v/markused/**.v'
- 'vlib/v/preludes/**.v'
- 'vlib/v/embed_file/**.v'
@@ -60,16 +76,17 @@ concurrency:
jobs:
tests-sanitize-undefined-clang:
runs-on: ubuntu-20.04
timeout-minutes: 180
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 240
env:
VFLAGS: -cc clang
VJOBS: 1
VTEST_SHOW_START: 1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 16
- name: Install dependencies
run: |
sudo apt-get update
@@ -77,7 +94,9 @@ jobs:
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install clang
- name: Build V
run: make -j4 && ./v -cg -cstrict -o v cmd/v
run: make && ./v -cg -cstrict -o v cmd/v
- name: Ensure code is well formatted
run: ./v test-cleancode
- name: Self tests (-fsanitize=undefined)
run: ./v -cflags "-fsanitize=undefined" -o v2 cmd/v && ./v2 -cflags -fsanitize=undefined test-self
- name: Build examples (V compiled with -fsanitize=undefined)
@@ -85,23 +104,26 @@ jobs:
tests-sanitize-undefined-gcc:
runs-on: ubuntu-20.04
timeout-minutes: 180
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 240
env:
VFLAGS: -cc gcc
VJOBS: 1
VTEST_SHOW_START: 1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 16
- name: Install dependencies
run: |
sudo apt update
sudo apt-get install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
- name: Build V
run: make -j4 && ./v -cg -cstrict -o v cmd/v
run: make && ./v -cg -cstrict -o v cmd/v
- name: Ensure code is well formatted
run: ./v test-cleancode
- name: Self tests (-fsanitize=undefined)
run: ./v -cflags "-fsanitize=undefined" -o v2 cmd/v && ./v2 -cflags -fsanitize=undefined test-self
- name: Build examples (V compiled with -fsanitize=undefined)
@@ -109,16 +131,17 @@ jobs:
tests-sanitize-address-clang:
runs-on: ubuntu-20.04
timeout-minutes: 180
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 240
env:
VFLAGS: -cc clang
VJOBS: 1
VTEST_SHOW_START: 1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 16
- name: Install dependencies
run: |
sudo apt update
@@ -126,7 +149,9 @@ jobs:
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install clang
- name: Build V
run: make -j4 && ./v -cg -cstrict -o v cmd/v
run: make && ./v -cg -cstrict -o v cmd/v
- name: Ensure code is well formatted
run: ./v test-cleancode
- name: Self tests (-fsanitize=address)
run: ASAN_OPTIONS=detect_leaks=0 ./v -cflags "-fsanitize=address,pointer-compare,pointer-subtract" test-self
- name: Self tests (V compiled with -fsanitize=address)
@@ -138,22 +163,28 @@ jobs:
tests-sanitize-address-msvc:
runs-on: windows-2019
timeout-minutes: 180
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 240
env:
VFLAGS: -cc msvc
VJOBS: 1
VTEST_SHOW_START: 1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 16
- name: Build
run: |
echo %VFLAGS%
echo $VFLAGS
.\make.bat -msvc
.\v.exe self
- name: Ensure code is well formatted
run: |
.\v.exe fmt -verify vlib/builtin/ vlib/v/scanner/ vlib/v/parser/ vlib/v/gen/
## TODO: check to see why `v test-cleancode` does not work with msvc on windows
## - name: Install dependencies
## run: |
## .\v.exe setup-freetype
@@ -164,16 +195,17 @@ jobs:
tests-sanitize-address-gcc:
runs-on: ubuntu-20.04
timeout-minutes: 180
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 240
env:
VFLAGS: -cc gcc
VJOBS: 1
VTEST_SHOW_START: 1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 16
- name: Install dependencies
run: |
sudo apt update
@@ -181,7 +213,9 @@ jobs:
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install clang
- name: Build V
run: make -j4 && ./v -cg -cstrict -o v cmd/v
run: make && ./v -cg -cstrict -o v cmd/v
- name: Ensure code is well formatted
run: ./v test-cleancode
- name: Self tests (-fsanitize=address)
run: ASAN_OPTIONS=detect_leaks=0 ./v -cflags -fsanitize=address test-self
- name: Self tests (V compiled with -fsanitize=address)
@@ -193,16 +227,17 @@ jobs:
tests-sanitize-memory-clang:
runs-on: ubuntu-20.04
timeout-minutes: 180
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 240
env:
VFLAGS: -cc clang
VFLAGS: -cc clang -gc none
VJOBS: 1
VTEST_SHOW_START: 1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 16
- name: Install dependencies
run: |
sudo apt update
@@ -210,11 +245,14 @@ jobs:
sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev
sudo apt-get install clang
- name: Build V
run: make -j4 && ./v -cc clang -cg -cstrict -o v cmd/v
run: make && ./v -cc clang -cg -cstrict -o v cmd/v
- name: Ensure code is well formatted
run: ./v test-cleancode
- name: Self tests (-fsanitize=memory)
run: ./v -cflags -fsanitize=memory test-self
- name: Self tests (V compiled with -fsanitize=memory)
run:
./v -cflags -fsanitize=memory -o v cmd/v && ./v -cc tcc test-self -msan-compiler
run: |
./v -cflags -fsanitize=memory -o v cmd/v
./v -cc tcc test-self -msan-compiler
- name: Build examples (V compiled with -fsanitize=memory)
run: ./v build-examples

View File

@@ -4,18 +4,25 @@ on:
push:
paths-ignore:
- "**.md"
- "**.yml"
pull_request:
paths-ignore:
- "**.md"
- "**.yml"
concurrency:
group: sdl-ci-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
v-compiles-sdl-examples:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 30
env:
VFLAGS: -cc tcc
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build V
run: make && sudo ./v symlink
@@ -40,7 +47,5 @@ jobs:
- name: Build sdl examples
run: |
for example in sdl/examples/*; do
echo "v $example"
v "$example";
done
v shader sdl/examples/sdl_opengl_and_sokol
v should-compile-all sdl/examples/

View File

@@ -10,7 +10,8 @@ on:
jobs:
toml-module-pass-external-test-suites:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 30
env:
TOML_BS_TESTS_PATH: vlib/toml/tests/testdata/burntsushi/toml-test
@@ -23,7 +24,7 @@ jobs:
VTEST_TOML_DO_YAML_CONVERSION: 1
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
@@ -44,7 +45,7 @@ jobs:
git -C $TOML_BS_TESTS_PATH checkout $TOML_BS_TESTS_PINNED_COMMIT
- name: Run BurntSushi TOML tests
run: ./v vlib/toml/tests/burntsushi.toml-test_test.v
run: ./v vlib/toml/tests/burntsushi_toml_test.v
# Tests found at gist
- name: Get large_toml_file_test.toml
@@ -60,7 +61,7 @@ jobs:
git -C $TOML_IARNA_TESTS_PATH checkout $TOML_IARNA_TESTS_PINNED_COMMIT
- name: Run iarna TOML tests
run: ./v -gc boehm vlib/toml/tests/iarna.toml-spec-tests_test.v
run: ./v -gc boehm vlib/toml/tests/iarna_toml_spec_test.v
# Tests found at https://github.com/alexcrichton/toml-rs
- name: Clone alexcrichton/toml-rs
@@ -69,4 +70,4 @@ jobs:
git -C $TOML_AC_TESTS_PATH checkout $TOML_AC_TESTS_PINNED_COMMIT
- name: Run alexcrichton TOML tests
run: ./v vlib/toml/tests/alexcrichton.toml-rs-tests_test.v
run: ./v vlib/toml/tests/alexcrichton_toml_rs_test.v

View File

@@ -0,0 +1,175 @@
name: V Apps and Modules
on:
push:
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
concurrency:
group: build-v-apps-and-modules-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
v-apps-compile:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
steps:
- uses: actions/checkout@v3
- name: Build V
run: make && sudo ./v symlink
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y libgc-dev libsodium-dev libssl-dev sqlite3 libsqlite3-dev valgrind libfreetype6-dev libxi-dev libxcursor-dev libgl-dev xfonts-75dpi xfonts-base
sudo apt-get install --quiet -y --no-install-recommends gfortran liblapacke-dev libopenblas-dev ## for vsl/vtl
sudo apt-get install --quiet -y --no-install-recommends sassc ## needed by gitly
sudo apt-get install --quiet -y --no-install-recommends libhdf5-cpp-103 libhdf5-dev libhdf5-mpi-dev hdf5-tools libopenmpi-dev opencl-headers liblapacke-dev libopenblas-dev ## needed by VSL
- name: Build vlang/vab
run: |
echo "Install VAB"
v install vab
echo "Build vab"
v ~/.vmodules/vab
echo "Build vab with -gc boehm -skip-unused"
v -gc boehm -skip-unused ~/.vmodules/vab
- name: Build vlang/ved
run: |
git clone --depth 1 https://github.com/vlang/ved
cd ved && ../v -o ved .
../v -autofree .
../v -prod .
cd ..
- name: Build vlang/pdf
run: |
v install pdf
echo "PDF examples should compile"
v should-compile-all ~/.vmodules/pdf/examples
- name: Build vlang/libsodium
run: |
echo "Install the libsodium wrapper"
v install libsodium
echo "Test libsodium"
VJOBS=1 v test ~/.vmodules/libsodium
- name: Build vlang/coreutils
run: |
echo "Clone Coreutils"
git clone --depth 1 https://github.com/vlang/coreutils /tmp/coreutils
echo "Build Coreutils"
cd /tmp/coreutils; make
# - name: Build vlang/gitly
# run: |
# echo "Install markdown"
# v install markdown
# echo "Install pcre"
# v install pcre
# echo "Clone Gitly"
# git clone https://github.com/vlang/gitly /tmp/gitly
# echo "Build Gitly"
# v /tmp/gitly
# ## echo "Build Gitly with -autofree"
# ## v -autofree /tmp/gitly
# echo "Compile gitly.css from gitly.scss"
# sassc /tmp/gitly/src/static/css/gitly.scss > /tmp/gitly/src/static/css/gitly.css
# echo "Run first_run.v"
# v run /tmp/gitly/tests/first_run.v
# # /tmp/gitly/gitly -ci_run
- name: Build V Language Server (VLS) vlang/vls
run: |
echo "Clone VLS"
git clone --depth 1 https://github.com/vlang/vls /tmp/vls
echo "Build VLS"
v /tmp/vls/cmd/vls
echo "Build VLS with -prod"
v -prod /tmp/vls/cmd/vls
echo "Build VLS with -gc boehm -skip-unused"
v -gc boehm -skip-unused /tmp/vls/cmd/vls
echo "Test VLS with gcc"
v -cc gcc test /tmp/vls
- name: Build vlang/go2v
run: |
echo "Clone Go2V"
git clone --depth=1 https://github.com/vlang/go2v /tmp/go2v/
echo "Build Go2V"
v /tmp/go2v/
echo "Run Go2V tests"
VJOBS=1 v -stats test /tmp/go2v/
- name: Install UI through VPM and make sure its examples compile
run: |
echo "Official VPM modules should be installable"
v install ui
echo "Examples of UI should compile"
v ~/.vmodules/ui/examples/build_examples.vsh
- name: Build vlang/vsl
run: |
echo "Installing dependencies"
sudo apt-get install --quiet -y --no-install-recommends \
gfortran \
libxi-dev \
libxcursor-dev \
mesa-common-dev \
liblapacke-dev \
libopenblas-dev \
libgc-dev \
libgl1-mesa-dev \
libopenmpi-dev \
opencl-headers
echo "Install VSL"
v install vsl
echo "Execute Tests using Pure V Backend"
~/.vmodules/vsl/bin/test
echo "Execute Tests using Pure V Backend with Pure V Math"
~/.vmodules/vsl/bin/test --use-cblas
echo "Execute Tests using Pure V Backend and Garbage Collection enabled"
~/.vmodules/vsl/bin/test --use-gc boehm
echo "Execute Tests using Pure V Backend with Pure V Math and Garbage Collection enabled"
~/.vmodules/vsl/bin/test --use-cblas --use-gc boehm
- name: Build vlang/vtl
run: |
echo "Install VTL"
v install vtl
echo "Install dependencies"
echo "Execute Tests using Pure V Backend"
~/.vmodules/vtl/bin/test
echo "Execute Tests using Pure V Backend with Pure V Math"
~/.vmodules/vtl/bin/test --use-cblas
echo "Execute Tests using Pure V Backend and Garbage Collection enabled"
~/.vmodules/vtl/bin/test --use-gc boehm
echo "Execute Tests using Pure V Backend with Pure V Math and Garbage Collection enabled"
~/.vmodules/vtl/bin/test --use-cblas --use-gc boehm
- name: Build vlang/adventofcode
run: |
echo "Clone the AdventOfCode repo"
git clone --depth 1 https://github.com/vlang/adventofcode /tmp/adventofcode
echo "Install dependencies"
v install pcre
echo "Execute Tests"
cd /tmp/adventofcode && v run verify.v
# - name: Build VEX
# run: |
# echo "Install Vex"
# v install nedpals.vex
# echo "Compile all of the Vex examples"
# v should-compile-all ~/.vmodules/nedpals/vex/examples
# echo "Compile the simple Vex example with -skip-unused"
# v -skip-unused ~/.vmodules/nedpals/vex/examples/simple_example.v
# echo "Run Vex Tests"
# v test ~/.vmodules/nedpals/vex

View File

@@ -11,6 +11,7 @@ on:
jobs:
vab-compiles-v-examples:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VAB_FLAGS: --api 30 --build-tools 29.0.0 -v 3
@@ -20,24 +21,18 @@ jobs:
distribution: 'adopt'
java-version: 8
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build V
run: make && sudo ./v symlink
- name: Checkout vab
uses: actions/checkout@v2
with:
repository: vlang/vab
path: vab
- name: Build vab
- name: Install vab
run: |
cd vab
v -g vab.v
sudo ln -s $(pwd)/vab /usr/local/bin/vab
v install vab
v -g ~/.vmodules/vab
sudo ln -s ~/.vmodules/vab/vab /usr/local/bin/vab
- name: Run tests
run: v test vab
run: v test ~/.vmodules/vab
- name: Run vab --help
run: vab --help
@@ -53,3 +48,27 @@ jobs:
safe_name=$(echo "$example" | sed 's%/%-%' | sed 's%\.%-%' )
vab examples/$example -o apks/$safe_name.apk
done
v-compiles-os-android:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- name: Build V
run: make && sudo ./v symlink
- name: Install vab
run: |
v install vab
v -g ~/.vmodules/vab
sudo ln -s ~/.vmodules/vab/vab /usr/local/bin/vab
- name: Run vab --help
run: vab --help
- name: Run vab doctor
run: vab doctor
- name: Check `v -os android` *without* -apk flag
run: .github/workflows/android_cross_compile.vsh

View File

@@ -1,34 +0,0 @@
name: Build Vinix kernel
on:
pull_request:
paths-ignore:
- "**.md"
push:
branches:
- master
paths-ignore:
- "**.md"
jobs:
vinix-build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install build-essential meson -y
- name: Build V
run: make
- name: Clone current Vinix
run: |
git clone https://github.com/vlang/vinix.git --depth 1
- name: Clone current mlibc
run: git clone https://github.com/managarm/mlibc.git --depth=1
- name: Patch mlibc for Vinix
run: cd mlibc && patch -p1 < ../vinix/patches/mlibc/0001-Vinix-specific-changes.patch || true
- name: Install mlibc headers
run: mkdir mlibc-build && cd mlibc-build && meson --cross-file ../vinix/cross_file.txt --prefix=/ -Dheaders_only=true ../mlibc && ninja && mkdir ../mlibc-headers && DESTDIR=`realpath ../mlibc-headers` ninja install
- name: Attempt to build the Vinix kernel (debug)
run: cd vinix/kernel && make PROD=false CFLAGS="-D__vinix__ -O2 -g -pipe -I../../mlibc-headers/include" V="../../v" && make clean
- name: Attempt to build the Vinix kernel (prod)
run: cd vinix/kernel && make PROD=true CFLAGS="-D__vinix__ -O2 -g -pipe -I../../mlibc-headers/include" V="../../v" && make clean

37
.github/workflows/vinix_kernel_ci.yml vendored Normal file
View File

@@ -0,0 +1,37 @@
name: Build Vinix kernel
on:
pull_request:
paths-ignore:
- "**.md"
push:
branches:
- master
paths-ignore:
- "**.md"
jobs:
vinix-build:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
env:
VFLAGS: -gc none
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install build-essential meson -y
- name: Build V
run: make
- name: Clone current Vinix
run: git clone https://github.com/vlang/vinix.git
- name: Attempt to build the Vinix kernel (debug)
run: cd vinix/kernel && make PROD=false CFLAGS="-D__vinix__ -O2 -g -pipe" V="../../v" && make clean
- name: Attempt to build the Vinix kernel (prod)
run: cd vinix/kernel && make PROD=true CFLAGS="-D__vinix__ -O2 -g -pipe" V="../../v" && make clean

View File

@@ -0,0 +1,119 @@
name: wasm backend CI
on:
push:
paths:
- '!**'
- '!**.md'
- 'cmd/tools/builders/**.v'
- 'vlib/builtin/**.v'
- 'vlib/v/ast/**.v'
- 'vlib/v/scanner/**.v'
- 'vlib/v/parser/**.v'
- 'vlib/v/checker/**.v'
- 'vlib/v/gen/c/**.v'
- 'vlib/v/builder/**.v'
- 'vlib/v/cflag/**.v'
- 'vlib/v/live/**.v'
- 'vlib/v/util/**.v'
- 'vlib/v/markused/**.v'
- 'vlib/v/preludes/**.v'
- 'vlib/v/gen/wasm/**.v'
- 'vlib/v/gen/wasm/tests/**.v'
pull_request:
paths:
- '!**'
- '!**.md'
- 'cmd/tools/builders/**.v'
- 'vlib/builtin/**.v'
- 'vlib/v/ast/**.v'
- 'vlib/v/scanner/**.v'
- 'vlib/v/parser/**.v'
- 'vlib/v/checker/**.v'
- 'vlib/v/gen/c/**.v'
- 'vlib/v/builder/**.v'
- 'vlib/v/cflag/**.v'
- 'vlib/v/live/**.v'
- 'vlib/v/util/**.v'
- 'vlib/v/markused/**.v'
- 'vlib/v/preludes/**.v'
- 'vlib/v/gen/wasm/**.v'
- 'vlib/v/gen/wasm/tests/**.v'
concurrency:
group: wasm-backend-ci-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
wasm-backend-ubuntu:
runs-on: ubuntu-22.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --quiet -y clang gcc
- name: Build V
run: make -j4 && ./v symlink -githubci
- name: Install binaryen as build dependency for the V WASM backend
run: ./v cmd/tools/install_binaryen.vsh
- name: Build the V WASM backend
run: ./v -cc clang -showcc -v cmd/tools/builders/wasm_builder.v
- name: Test the WASM backend
run: ./v test vlib/v/gen/wasm/tests/
- name: Build examples
run: VTEST_ONLY=wasm ./v build-examples
wasm-backend-macos:
runs-on: macOS-12
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
steps:
- uses: actions/checkout@v3
- name: Build V
run: make -j4 && ./v symlink -githubci
- name: Install binaryen as build dependency for the V WASM backend
run: ./v cmd/tools/install_binaryen.vsh
- name: Build the V WASM backend
run: ./v -cc clang -showcc -v cmd/tools/builders/wasm_builder.v
- name: Test the WASM backend
run: ./v test vlib/v/gen/wasm/tests/
- name: Build examples
run: VTEST_ONLY=wasm ./v build-examples
wasm-backend-windows:
runs-on: windows-2022
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
steps:
- uses: actions/checkout@v3
- name: Build V
run: .\make.bat -msvc
- name: Symlink V
run: .\v.exe symlink -githubci
- name: Install binaryen as build dependency for the V WASM backend
run: v cmd/tools/install_binaryen.vsh
- name: Build the V WASM backend
run: v -cc msvc -showcc -v cmd/tools/builders/wasm_builder.v
- name: Test the WASM backend
run: v -stats test vlib/v/gen/wasm/tests/
- name: Build examples
run: $env:VTEST_ONLY='wasm'; v build-examples

View File

@@ -0,0 +1,73 @@
name: wasm wabt validate tests CI
on:
push:
paths:
- '!**'
- '!**.md'
- 'vlib/builtin/**.v'
- 'vlib/wasm/**.v'
- 'vlib/wasm/tests/**.v'
pull_request:
paths:
- '!**'
- '!**.md'
- 'vlib/builtin/**.v'
- 'vlib/wasm/**.v'
- 'vlib/wasm/tests/**.v'
concurrency:
group: wasm-wabt-ci-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
wasm-wabt-ubuntu:
runs-on: ubuntu-22.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 31
steps:
- uses: actions/checkout@v3
- name: Build V
run: make && ./v symlink -githubci
- name: Install wabt to get the wasm-validate executable
run: v cmd/tools/install_wabt.vsh
- name: Test the WASM backend
run: v test vlib/wasm/
wasm-wabt-macos:
runs-on: macOS-12
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 31
steps:
- uses: actions/checkout@v3
- name: Build V
run: make && ./v symlink -githubci
- name: Install wabt to get the wasm-validate executable
run: v cmd/tools/install_wabt.vsh
- name: Test the WASM backend
run: v test vlib/wasm/
wasm-wabt-windows:
runs-on: windows-2022
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 31
steps:
- uses: actions/checkout@v3
- name: Build V
run: .\make.bat -msvc
- name: Symlink V
run: .\v.exe symlink -githubci
- name: Install wabt to get the wasm-validate executable
run: v cmd/tools/install_wabt.vsh
- name: Test the WASM backend
run: v test vlib/wasm/

View File

@@ -11,11 +11,12 @@ on:
jobs:
websocket_tests:
runs-on: ubuntu-20.04
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc tcc -no-retry-compilation
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install dependencies
run: sudo apt-get install --quiet -y libssl-dev
- name: Build v

View File

@@ -1,12 +1,11 @@
@echo off
curl -L https://www.sqlite.org/2020/sqlite-amalgamation-3320300.zip -o sqlite-amalgamation-3320300.zip
curl -L https://www.sqlite.org/2022/sqlite-amalgamation-3380200.zip -o sqlite-amalgamation-3380200.zip
unzip sqlite-amalgamation-3320300.zip -d thirdparty\
unzip sqlite-amalgamation-3380200.zip -d thirdparty\
del thirdparty\sqlite-amalgamation-3320300\shell.c
del thirdparty\sqlite-amalgamation-3380200\shell.c
move /y thirdparty\sqlite-amalgamation-3320300 thirdparty\sqlite
move /y thirdparty\sqlite-amalgamation-3380200 thirdparty\sqlite
dir thirdparty\sqlite

223
.github/workflows/windows_ci.yml vendored Normal file
View File

@@ -0,0 +1,223 @@
name: Code CI Windows
on:
push:
paths-ignore:
- "**.md"
- "**.yml"
pull_request:
paths-ignore:
- "**.md"
- "**.yml"
concurrency:
group: build-ci-windows-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
windows-gcc:
runs-on: windows-2019
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 181
env:
VFLAGS: -cc gcc
VERBOSE_MAKE: 1
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Build
run: |
gcc --version
.\make.bat -gcc
- name: Test new v.c
run: |
.\v.exe -o v.c cmd/v
gcc -Werror -municode -w v.c
- name: Install dependencies
run: |
.\v.exe setup-freetype
.\.github\workflows\windows-install-sqlite.bat
- name: v doctor
run: |
./v doctor
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests
run: .\v.exe test-self
# - name: Test
# run: .\v.exe test-all
- name: Test time functions in a timezone UTC-12
run: |
tzutil /s "Dateline Standard Time"
./v test vlib/time/
- name: Test time functions in a timezone UTC-3
run: |
tzutil /s "Greenland Standard Time"
./v test vlib/time/
- name: Test time functions in a timezone UTC+3
run: |
tzutil /s "Russian Standard Time"
./v test vlib/time/
- name: Test time functions in a timezone UTC+12
run: |
tzutil /s "New Zealand Standard Time"
./v test vlib/time/
- name: Test v->js
run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test v binaries
run: ./v build-vbinaries
- name: Build examples
run: ./v build-examples
- name: v2 self compilation
run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v
windows-msvc:
runs-on: windows-2019
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 181
env:
VFLAGS: -cc msvc
VERBOSE_MAKE: 1
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Build
run: |
echo %VFLAGS%
echo $VFLAGS
.\make.bat -msvc
.\v.exe -cflags /WX self
- name: Install dependencies
run: |
.\v.exe setup-freetype
.\.github\workflows\windows-install-sqlite.bat
- name: v doctor
run: |
./v doctor
- name: Verify `v test` works
run: |
echo $VFLAGS
./v cmd/tools/test_if_v_test_system_works.v
./cmd/tools/test_if_v_test_system_works
### TODO: test-cleancode fails with msvc. Investigate why???
## - name: All code is formatted
## run: ./v test-cleancode
- name: Self tests
run: |
./v -cg cmd\tools\vtest-self.v
./v test-self
# - name: Test
# run: .\v.exe test-all
- name: Test v->js
run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test v binaries
run: ./v build-vbinaries
- name: Build examples
run: ./v build-examples
- name: v2 self compilation
run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v
windows-tcc:
runs-on: windows-2019
if: github.event_name != 'push' || github.event.ref == 'refs/heads/master' || github.event.repository.full_name != 'vlang/v'
timeout-minutes: 121
env:
VFLAGS: -cc tcc -no-retry-compilation
VJOBS: 1
VTEST_SHOW_START: 1
VERBOSE_MAKE: 1
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Build with make.bat -tcc
run: |
.\make.bat -tcc
- name: Test new v.c
run: |
.\v.exe -o v.c cmd/v
.\thirdparty\tcc\tcc.exe -Werror -w -ladvapi32 -bt10 v.c
- name: Install dependencies
run: |
.\v.exe setup-freetype
.\.github\workflows\windows-install-sqlite.bat
- name: v doctor
run: |
./v doctor
- name: Verify `v test` works
run: |
.\v.exe cmd/tools/test_if_v_test_system_works.v
.\cmd\tools\test_if_v_test_system_works.exe
- name: Verify `v vlib/v/gen/c/coutput_test.v` works
run: |
.\v.exe vlib/v/gen/c/coutput_test.v
- name: Make sure running TCC64 instead of TCC32
run: ./v test .github\workflows\make_sure_ci_run_with_64bit_compiler_test.v
- name: Test ./v doc -v clipboard *BEFORE building tools*
run: ./v doc -v clipboard
- name: Test v build-tools
run: ./v -W build-tools
- name: All code is formatted
run: ./v test-cleancode
- name: Self tests
run: ./v test-self
- name: Test v->js
run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test v binaries
run: ./v build-vbinaries
- name: Build examples
run: ./v build-examples
- name: v2 self compilation
run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v && .\v3.exe -o v4.exe cmd/v
- name: v2 self compilation with -gc boehm
run: .\v.exe -o v2.exe -gc boehm cmd/v && .\v2.exe -o v3.exe -gc boehm cmd/v && .\v3.exe -o v4.exe -gc boehm cmd/v
## ## tcc32
## - name: Build with make.bat -tcc32
## run: |
## Remove-Item -Recurse -Force .\thirdparty\tcc
## .\v.exe wipe-cache
## .\make.bat -tcc32
## - name: Test new v.c
## run: .\v.exe -o v.c cmd/v && .\thirdparty\tcc\tcc.exe -Werror -g -w -ladvapi32 -bt10 v.c
## - name: v doctor
## run: ./v doctor
##
## - name: Verify `v test` works
## run: |
## .\v.exe cmd/tools/test_if_v_test_system_works.v
## .\cmd\tools\test_if_v_test_system_works.exe
##
## - name: Verify `v vlib/v/gen/c/coutput_test.v` works
## run: |
## .\v.exe vlib/v/gen/c/coutput_test.v
##
## - name: Make sure running TCC32 instead of TCC64
## run: ./v -stats .github\workflows\make_sure_ci_run_with_32bit_compiler_test.v
##
## - name: Test v build-tools
## run: ./v -W build-tools
##
## - name: Test ./v doc clipboard
## run: ./v doc clipboard
##
## - name: Self tests
## run: ./v test-self
## - name: Test v->js
## run: ./v -o hi.js examples/hello_v_js.v && node hi.js
## - name: Test v binaries
## run: ./v build-vbinaries
## - name: Build examples
## run: ./v build-examples
## - name: v2 self compilation
## run: .\v.exe -o v2.exe cmd/v && .\v2.exe -o v3.exe cmd/v

18
.gitignore vendored
View File

@@ -31,6 +31,10 @@ a.out
/v.c.out
/v_old
/v_old.exe
/vold
/vold.exe
/vnew
/vnew.exe
.vrepl_temp.v
fns.txt
.noprefix.vrepl_temp.v
@@ -57,6 +61,7 @@ fns.txt
.project
.classpath
.c9
.vs
*.launch
.settings/
*.sublime-workspace
@@ -73,6 +78,7 @@ cachegrind.out.*
.gdb_history
*.dSYM
*.def
vgcore.*
# ignore system files
.DS_Store
@@ -102,6 +108,18 @@ flake.nix
.envrc
thirdparty/stdatomic/nix/cpp/*.h
thirdparty/binaryen*
thirdparty/wabt*
# ignore VLS log
vls.log
# ignore v2go tmperror files
*.tmperr
*/**/tmp.*
# ignore Intellij files
.idea/
/*.iml
wasm.v

View File

@@ -1,15 +1,444 @@
-## V 0.2.5
-*Not yet released, changelog is not full*
- Introduce `isize` and `usize` types, deprecate `size_t` in favor of `usize`
## V 0.3.5
*not yet released*
- A new VPM site: vpm.vlang.io. A better design, discoverability of packages, descriptions, most downloaded packages etc.
- Struct fields can now be skipped during JSON/ORM serialization via `[json:'-']` and `[sql:'-']`,
in addition to `[skip]`. This allows having custom behavior for different serialization methods.
- ORM: fixed a foreign key bug that could result in an extra insert.
- Generic functions as function parameters are now supported: `fn f[T](x T, i int, f_ Fn[T]) T { `.
- Enum values now can have attributes.
- json: Enum value string serialization supports `[json:'alias']` to change its string values.
- Functions can now return fixed size arrays.
- The builtin websocket library is now thread safe.
- Enhanced builtin csrf protection in vweb.
- builtin: heap usage API (gc_memory_use() and gc_heap_usage())
-## V 0.2.4
-*Not yet released, changelog is not full*
## V 0.3.4
*30 Apr 2023*
### Breaking Changes
The following changes may break compilation of existing code or change behavior at runtime:
- `json`: enums are serialized as strings by default, `[json_as_number]` attribute can be used for
the old behavior.
If you are serializing enums to JSON in your application, then you will need to add the
`[json_as_number]` attribute to keep the old behavior!
- Variable shadowing has been completely banned (previously variable names could conflict with
module names).
### Web
- vweb now supports live page reloading.
The web app is instantly updated in the browser (no need to refresh the page)
every time a **.v** or a **.html** file is changed.
- vweb is now significantly faster and more stable under load, due to a new multithreaded worker
pool, which is much more efficient at spreading the workload among all threads equally.
- vweb now supports middleware.
- vweb now supports controllers.
It's now possible to have multiple app structs to better separate logic.
- vweb now supports overridable `.not_found()` method for custom 404 pages in vweb.
- vweb now uses database pool.
- Fixed multipart form parsing in vweb.
### Backends
- A new pure WASM backend, based on binaryen, a WASM `builtin` module, and a pure V WASM
serialization library.
- Lots of fixes and new features in the native backend, including making codegen logic
platform independent.
- Now code generated by the С backend, can be compiled by a C++20 compiler.
- C backend does not generate unused interface functions now.
### Compiler CLI
- `v share file.v` for sharing code via the playground.
- `v up` speed up for when it hasn't been run for a long time (**vc/** bootstrapping has been
optimized).
- `v init` no longer overwrites existing `src/main.v`.
- `v self` now uses a faster TCC backend on macOS (Intel/Apple Silicon), just like on Windows/Linux.
- A new command line flag `-e` for running short V programs on command line: `v -e "println(2+5)"` (
works just like in Perl).
- A new `-ldflags` option, in addition to `-cflags`. Works just like LDFLAGS in C.
### ORM
- All ORM queries now return `![]` (`Result` of an array).
This allows handling/propagating DB errors and simplifies working with ORM (one way).
- Many ORM improvements: type checks for `limit/offset/order by/where`; support of reference objects
in `insert`; struct fields can be used with `limit/offset`; `Connection` interface.
- ORM now supports the `like` operator:
```v
users := sql db {
select from User where name like 'Bob%'
}
```
- A new `-d trace_orm` option to see all SQL queries generated and used by V ORM and
`-d trace_pg_error` to trace PG errors.
### Standard Library
- Added new `termios` module.
- `net.ssl`: types using ssl contexts can now be converted to strings via `.str()`/printed
via `println()`.
- `v.reflection`: added type symbol info metadata.
- `crypto` and `math` modules have been updated to use `Result` instead of `Option`.
- `datatypes.LinkedList[map]` now works correctly.
- `urllib.Values.get()` now returns an Option.
- `strconv`: `v_printf()` was made private, `v_sprintf()` was deprecated. String interpolation
should be used instead.
- `net.http`: mime types have been updated to include all official types.
- `gg`: `create_image()` now returns `!Image` instead of `Image`, allowing to handle errors.
- `sokol`: errors during image creation no longer result in a panic, but can be handled by the
programmer.
- `sokol`: macOS apps can now be quit using **Cmd+Q**.
- `os.hostname()` and `os.loginname()` now return `Result`.
- `strconv.atoi` optimizations.
- `println()` now supports arrays with recursive references.
- `termux`: support for cross-compilation from termux to other platforms.
- `readline` module now works much better on macOS: key navigation, history, etc (now on par with
Linux).
- `os`: fixed a memleak in `getline()`.
- `os.Process` now has a `create_no_window` option (Windows only).
- `os.Process` now has a `set_work_folder()` method to set the initial working folder of the new
child process.
### Option as a first class type
Final steps in making the Option type a first class type:
- If guards now work with struct fields which are `Option` functions.
Such fields can now also be assigned to other fields/variables.
- Option receivers can no longer have methods.
- `none` can now be cast to all `Option` types, including aliases.
- Option references are now supported: `?&Type`.
- Arrays of `Option`s are now allowed.
- Allow `foo := Foo{}`, when `Foo` has an Option field, that is a struct, that has a `[required]`
tag on its fields.
### Compile-time Reflection
- Compile-time interface fields evaluation.
- Compile-time enum evaluation:
```v
$for item in MyEnum.fields {
println(item.value)
println(item.name)
}
```
- Added `$option` as a compile-time reflection type representing an any Option type.
- All special compile-time reflection types are now lowercase (`$int`, `$enum`, `$option`, etc).
### Checker Improvements/Fixes
- Enums can no longer be initialized like structs.
- Capture variables can no longer shadow anonymous function params.
- Mixing multi-return results with other types in return statements is no longer allowed.
- Assigning anonymous structs to named structs is no longer allowed.
- `[required]` fields are now checked for embedded structs.
- Fixed a bug with closures with fixed array variables.
- Builtin methods `first/last/repeat` can now be used in custom user types (previously they only
worked in builtin arrays).
- Generic struct initialization no longer needs explicit types to be provided:
```v
struct Foo[T, U] {
a T
b U
}
foo := Foo{
a: 2
b: 'x'
}
println(foo)
```
- unsafe: dereferencing nil references is no longer allowed in the following case:
```v
a := unsafe { nil }
println(*a)
```
### OSes
- Added basic QNX support.
### Other changes
- Lots of documentation/readme improvements.
- Lots of playground improvements: [play.vlang.io](https://play.vlang.io), including a really cool
feature: "Show generated C code".
- A new `[spawn_stack: 131072]` function attribute for controlling the max size of the stack of the
spawned threads.
- Channel pop now works with an `or` block: `ch := <-self.item or { return none }`
- `it` has been renamed to `index` in array inits.
- "Is V still fast?" web-page has been sped up by splitting the result table into multiple years.
### Development
- GitHub Copilot summaries in PRs.
## V 0.3.3
*30 Jan 2023*
- String interpolation simplified to just '${name}', enforced by vfmt, and updated in the entire code base.
- `[]` is now used for generics instead of `<>`.
- Various ORM fixes and improvements, including string interpolation support, type checks, fn calls in `where`.
- Accessing a pointer map value requires an `or {}` block outside `unsafe`.
- `math.vec` module for generic vector math including 2D, 3D, and 4D vector operations.
- `go foo()` has been replaced with `spawn foo()` (launches an OS thread, `go` will be used for
upcoming coroutines instead).
- vfmt now supports `// vfmt off` and `// vfmt on` for turning off the formatting locally for short snippets of code.
Useful for keeping your carefully arranged matrices intact.
- fast.vlang.io fixes & improvements, new server.
- New official IntelliJ plugin: https://intellij-v.github.io.
- Lots of fixes in the type checker.
- Match branch range expressions with consts: `match x { const1...const2 {} }`
- Builtin stb_image.h used by gg has been updated to the latest v2.28.
- Lots of new language documentation, a nicer table of contents.
- Improved documentation for most of the vlib modules
- All of vlib has been updated to use separate Option/Result types.
- To avoid confusion, all references in the code and documentation to `Optional` have been replaced with `Option`.
- `gg.Context` pipeline has more effects, including the `additive` effect.
- Hot code reloading via `[live]` is now supported in imported modules, not just the main module.
- VFS support in the builtin `sqlite` module; `sqlite.get_affected_rows_count()`.
- `make.bat` & `v up` improvements on Windows.
- Syntax sugar for map inits without needing explicit casts for interfaces: `all.children := { "abc": rect, "def": ui.rectangle()}`.
- `$embed_file()` fixes, including variable args support.
- `none` fixes: no longer allowed to be used as a separate type, `dump()` support, not allowed inside `unsafe`.
- Much cleaner eof checks in `os`: refactor `err == IError(os.Eof{})` to `err is os.Eof`.
- Const functions: `const y = term.yellow`, then `println(y('abc'))`.
- Lots of work on `x.json2`, the pure V json encoder, soon to become official.
- Improved compile time checks, like `$if x is Type {`; `$if T in [$Array, $Struct, $Alias, $Function] {`.
- New `v.reflection` module for runtime reflection.
- Improved `os.mv()`, which now works consistently even across different windows drives/mount points.
- `string.trim_indent()`, useful with multi line strings, that start/end with new lines and indentation.
- Reduced memory consumption in the `crypto` modules.
- Installation instructions for using V on NixOS.
- TeamCity test runner support via `v -test-runner teamcity foo_test.v`.
- Better `make` support for OpenBSD.
- Much improved experience for `v install pcre` on Windows (it now bundles its own .c files, so it compiles cleanly, even if the platform does not have another pcre package installed).
- Improved vweb stability under load.
- Improved `pg` compatibility with older PostgreSQL versions before 2014.
- Native backend: operator support for floats, multi return.
- V can now be compiled with tcc on latest macOS and Apple Silicon.
- CI optimizations for faster runs.
- Official V UI library is now licensed under MIT.
- Deprecated `math.util` and `math.mathutil` have been removed.
- Builtin type names can no longer be used as identifiers.
- Generic `typeof[T]()`, `sizeof[T]()`, `isreftype[T]()` functions.
- New official AdventOfCode repo with AOC solutions, also added to CI.
- New time format support: `time.format_rfc3339()`.
- `encoding.html.escape()`.
- Deprecated `-error-limit` in favour of the documented `-message-limit` option.
- Maps now support aliased keys.
- Operator overloading now works with reference types.
- Generic struct inits with nested generic structs and generic optional types are now allowed.
- During array creation, `len:` is required when using default values for the array.
- Optimized one byte `[]u8` arrays creation.
- Int signedness mismatch is now checked: `cannot use literal signed integer as u8`.
- New comptime features for fields: `field.is_<field>`, `field.is_alias`, `field.is_enum`.
- More detailed timings in `v -show-timings`.
- `$for in` works with alias types.
- `v new <name> web` for quickly scaffolding new web projects.
- All public functions in the `hash` and `encoding.base32` modules have been documented.
- Recursive aliasing is no longer allowed (e.g. `type Alias = map[string]Alias`).
- `sqlite`, `pg`, `mysql` have been moved to `db.sqlite`, `db.pg`, `db.mysql`.
- New `crypto.pem` module.
- New `map.reserve()` method.
## V 0.3.2
*31 Oct 2022*
- New simplified string interpolation: `println("Hello, {name}!")`. It will be the only way, old syntax (`${name}` and `$name`)
will be deprecated.
- New stunning playground with an improved look and feel, a much better and more responsive editor,
code sharing by link, more convenient keyboard control, reusability for potential embedding:
https://play.vlang.io.
- `net.ssl` has been migrated from a dynamically linked OpenSSL to a statically linked Mbed TLS. This means that V binaries will no
longer have an OpenSSL dependency. OpenSSL can still be enabled via `-d use_openssl`.
- msgpack module for decoding/encoding msgpack. (`v install msgpack`)
- Easier custom error creation: `return MyCustomErr{}` instead of `return IError(MyCustomErr)`.
- Lots of native backend improvements, including library calls, comptime conditionals, enums, method definitions/calls, structs.
- Removed the need for the `[console]` attribute in Windows GUI apps.
- All floats outputs now have `.0` conditionally appended to them to improve clarity.
- Improved type checker: lots of new type checks and fixed checker bugs.
- Custom integer enum types: `enum Xyz as u64 {`.
- Some further interpreter work.
- Improved call tracing via `-trace-calls`.
- Most of vlib has been updated to use the new Option/Result types.
- Lots of documentation improvements, including a better documentation of the recent Option/Result split.
- net, net.http, vweb bugs and fixes.
- V REPL: Home/End keys support. Lots of clean up.
- QuadTree and RingBuffer types in `datatypes`.
- Forward iterator for `datatypes.LinkedList<T>`, forward and backward iterators for `datatypes.DoublyLinkedList<T>`.
- More precise WINAPI declarations for easier integration on Windows.
- Unused last expression in `if` is now checked.
- AST transformer fixes and optimizations.
- cgen cleanups.
- Lots of fixes in the builtin `dump()` function.
- Stylistic improvements and bug fixes in vfmt.
- Casting integers to enums now requires `unsafe{}`.
- Improved error and warning messages.
- A new `maps` module, similar to existing `arrays`. It has generic `filter`, `flatten`, `invert`, `to_map`, `to_array`, `from_array`
functions.
- Parallel compilation now uses `sync.Pool`.
- `utf8.is_number()`, `utf8.is_space()` functions.
- New `encoding.base32` module.
- `-skip-unused` fixes, soon to be made the default.
- `gg.TouchPoint` to differentiate between different types of touch input.
- Anonymous structs visibility issues fixed.
- orm: support parenthesized expressions like `select from User where (name == 'Sam' && is_customer == true) || id == 1`.
- `vweb.csrf` module.
- `str.int()` conversion speedup (without -prod).
- More CI tests on FreeBSD.
## V 0.3.1
*31 Aug 2022*
- Anonymous structs.
- Lots of bug fixes: 90% of all bugs ever submitted are closed.
- Major improvements to the fast native backend including linking support on Linux. The goal is to be able to self host V soon.
- Parallelized cc step. Speeds up -prod and clang/gcc compilation by 300-500% (depending on
the number of cores). Experimental and hidden behind a -parallel-cc flag, soon to be the default.
- New keyword/type: `nil`. Only to be used inside `unsafe`. Replaces `voidptr(0)`.
- V can now find code in the `src/` directory. This allows making V repos much cleaner.
- Intel C compiler support.
- Older macOS support (<10.12).
- `os.mkdir()` now has an optional `mode` parameter.
- Full termux support via `$if termux {`, more predictable logging on Android.
- Go backend fixes.
- More type checks.
- DOOM is now translated/compiled and launched on CI servers. A screenshot of the running game
is made via `vgret` and is compared to the expected result.
- VLS performance improvements, especially on Windows.
- `v ls` tool for installing, for updating, and for launching VLS (V Language Server).
- Support `assert condition, extra_message`, where the `extra_message` will be evaluated and shown if the assertion fails.
- Anonymous sumtypes have been removed (deprecated for now) due to complicating the language and the compiler too much.
- `encoding.csv` is now generic, supports bools, accepts a custom delimiter, and is compatible with io.Reader/io.Writer.
- Operator overloading now works with aliases and generics.
- `datatypes` module now uses operator overloading.
- All `datatypes` types can be converted to V arrays.
- `smtp` improvements including multiple recipients and base64/utf8 support.
- `v doc` now has syntax highlighting.
- `arrays.carray_to_varray<T>()` for converting C arrays to V arrays.
- `strconv.v_sprintf()` has been deprecated in favor of string interpolation.
- TOML module now supports `[toml:...]` attributes, just like the JSON module.
- `os.walk()` is no longer recursive (still works the same).
- Windows code has been removed from `v.c` distributed on non-Windows systems. (`v_windows.c` is used on Windows.)
- ORM functions now return `Result`, so the errors can be handled.
- `#preinclude` for low level C interop.
- `net.urllib` ipv6 support.
- Lots of fixes in `shared` types.
- `io` has been migrated to `Result`.
- Third party window control in Sokol.
- Scanner optimizations.
- `string.replace_char()`, `math.round_sig()`.
- Improved multiplication performance in `math.big`.
- `net.Http.Response.text` renamed to `body`.
- Using C's #define is no longer allowed in normal V code, only in `.c.v` files.
- V interpreter improvements.
- `net.websocket` timeout is now configurable.
## V 0.3
*30 Jun 2022*
- C to V translation via C2V: `v translate file.c`. (Demo video: [Translating DOOM from C to V, building it in under a second and running it!](https://www.youtube.com/watch?v=6oXrz3oRoEg))
- Lots of bug fixes in V, cgen, and C interop to allow running translated DOOM.v.
- Programs built with the V compiler no longer leak memory by default.
- Closures. All operating systems are supported. ([Demo](https://twitter.com/v_language/status/1528710491882852352))
- `Option` and `Result` are now separate types: `?Foo` and `!Foo` respectively. Old code will continue working for 1 year and will result in a warning/hint.
- Hundreds of new checks in the type checker.
- All V's backends have been split up into separate processes. As the result, building V got 26% faster.
- Maps and arrays can now return options: `m[bad_key] or { ... }`, `if x := arr[key] { ... }`.
- `ustring` has been replaced with `[]rune` (works just like in Go).
- Maps can now have non-string keys.
- A new compiler pass for transforming the AST (doesn't slow the compiler too much, adds about 25ms to `v self`). It eliminates unreachable branches and performs other simple optimizations and transformations.
- C backend is now parallel (just the cgen part for now).
- Lots of compiler source code clean up and minor optimizations. The compiler got ~30% faster according to fast.vlang.io.
- Better compiler source code organization (absolutely necessary as it's surpassed 100k loc).
- The naming of V's integer types is now more consistent: `byte` has been renamed to `u8`. Old code will continue working for 1 year and will result in a warning/hint.
- The typo detector now highlights the suggested name so that it's more visible.
- `datatypes` module now has `Heap, Queue, Stack, BSTree, LinkedList`.
- Interfaces can now be embedded (like structs).
- vlib now has a TOML parser, fully compatible with TOML 1.0.
- Lots of work done on the V.js backend, including the graphics library, which has been ported to V.js.
- JS promises, await (V.js).
- It's now possible to do more complex array initialization by using each individual element of the array (`[]int{init: it}`).
- Unsigned right shift operators `>>>` and `>>>=` have been added to V. (They work exactly like in Java.)
- `-nofloat` option, which is useful for writing kernels and for embedded systems without an FPU (used in Vinix).
- Generic interfaces.
- TCC is now bundled with the language, this allows building V programs without an external C compiler dependency.
- Null can be used in `unsafe` only (for example, for C interop).
- Pointer arithmetic and comparing pointers to numbers is now also only allowed in `unsafe`.
- Inline sumtypes.
- New module `compress.gzip`.
- Lots of `net`/`net.http`/`vweb` fixes (also used for the upcoming Gitly launch).
- IPv6 support.
- `net.http` headers are now enum fields instead of strings. This allows to avoid typos and offers autocomplete.
- Struct field deprecation.
- Static GC (no longer a dynamic lib dependency).
- New various algorithms for random number generation: MT19937RNG, etc (module `rand`).
- Fix immutability bugs that allowed to bypass compiler immutability checks and modify const/immutable values.
- Lots of fixes in the JSON serializer.
- Heap allocated only structs marked with `[heap]`.
- Significantly improve lots of error messages, make them more clear, suggest hints.
- Bug fixes and new features in the pure V `regex` module.
- Lots of new drawing functions in the graphics module (like `gg.draw_polygon_filled(), gg.draw_arc_empty()` etc)
- Builtin FPS display in `gg`.
- Latest Sokol backend in `gg`.
- Advanced CI tests for the graphics module. Graphical apps are run on GitHub Actions instances, their output is saved to an image, uploaded, and compared to the expected result.
- More bug fixes in generics.
- Bug fixes in aliases. They can now fully replace the types they alias.
- `[minify]` struct attribute for struct minification.
- `for in` now works with fixed arrays.
- The parser was made a bit faster by skipping `vfmt` code when not in `vfmt` mode (by using `-d vfmt`).
- Lots of vfmt improvements, especially with comments.
- Experimental `#[index]` syntax for negative indexing (like in Python, but needs special syntax instead of being used by default).
- Visibility bug fixes in modules (`pub`).
- Error propagation in complex expressions (e.g. `foo(bar()?)`).
- Optionals can now by used in consts (`const x := opt() or {}`).
- Lots of new documentation, including vlib modules documentation and the official V Documentation.
- vpm improvements (including a new vpm mirror).
- `sync` improvements including `sync.thread_id()`, `sync.Once`..
- V can now be used to generate object files (`foo.o`) that can be used in existing C projects.
- `-usecache` and `-skip-unused` fixes, they are close to being on by default.
- Lots of Windows issues fixed.
- Amazon Linux support.
- Fixes in shared maps and arrays.
- `term.ui` improvements, including multi byte/UTF-8 events.
- New `crypto` modules, including `crypto.des, crypto.cipher, crypto.blowfish`.
- Comptime fixes.
- 4 byte bool option (`-d 4bytebool`) for compatibility with some C software.
- `strconv` (pure V formatting module used in string interpolation) fixes and performance improvements.
- ORM fixes (pg, mysql, sqlite). Tables are now created automatically based on the V structs, no more need in sql files to create tables for apps.
- `volatile` keyword.
- `"stringliteral".len` optimization (replaced by the actual number by the new `transform` pass).
- Lots of inline assembler improvements (it's used a lot in Vinix).
- Many new functions in the `math` module.
- Separators in number literals: `1_000_000`.
- `strings.Builder` optimizations and new methods.
- Autofree fixes (still not production ready, hidden behind the `-autofree` flag).
- Lots of Android fixes in V and in vab.
- Lots of commits to the native backend (amd64/arm64).
- V interpreter fixes. (Still at an early stage.)
- Go2V translator has been started by the community, and can already translate simple programs.
- An early version of the Go backend (`v -b go -o file.go file.v`).
## V 0.2.4
*30 Aug 2021*
- Introduce `isize` and `usize` types, deprecate `size_t` in favor of `usize`.
- Add `datatypes` and `datatypes.fsm` modules.
- Add `compile_error` and `compile_warn` comptime functions.
- Bare metal support. Vinix OS kernel is now being developed in V.
- Builtin web framework vweb is now multithreaded, all CPU cores are used.
- String interpolation and struct stringers are now implemented in pure V
with a much cleaner and faster implementation. Previously libc's `sprintf`
was used.
- Improved `unused variable` warning. Assigning to a variable no longer marks it as used.
*... lots of missing changelog for this version, sorry (will update a bit later)*
## V 0.2.2 - 0.2.3
*22 Jan 2021*
@@ -49,12 +478,11 @@ from local variables.
## V 0.2
*22 Dec 2020*
- Compile-time memory management via `-autofree`. [Video demonstration](https://www.youtube.com/watch?v=gmB8ea8uLsM).
It will be enabled by default in 0.3
- Compile-time memory management via `-autofree` (not production ready yet). [Video demonstration](https://www.youtube.com/watch?v=gmB8ea8uLsM).
- Channels and locks.
- Thread safe typed arrays via keyword `shared`.
- Struct embedding.
- IO streams.
- IO streams (`io.Reader`, `io.Writer` etc).
- A powerful websocket module that conforms to RFC 6455 and passes the Autobahn test suite (498 client tests and 249 server tests).
- The `net` module is now non blocking and is more feature complete providing similar API to Go.
- V's graphics module now uses Metal/DirectX/OpenGL instead of just OpenGL.
@@ -201,7 +629,7 @@ files with compilation errors.
- V now enforces short enum syntax (`.green` instead of `Color.green`) when it's enough.
- V UI for macOS.
- Interfaces have been rewritten. `[]interface` support.
- `os.cp()` for copying files and directores.
- `os.cp()` for copying files and directories.
- Additional compile-time flags: `$if clang, msvc, mingw, x32, x64, big_endian, little_endian {`.
- All C functions now have to be declared, all missing C functions have been defined.
- Global variables (only with the `-enable-globals` flag)
@@ -264,14 +692,14 @@ used in some industries.
- `fn init()` for module initialization.
- `a in [1, 2, 3]` optimization: no array gets allocated.
- Raw strings: `s := r'hello\nworld'`.
- `if a := func() { }` syntax for handling optionals.
- `if a := func() { }` syntax for handling options.
- f32/f64 comparison now uses machine epsilon by default.
## V 0.1.21
*30 Sep 2019*
- `none` keyword for optionals.
- `none` keyword for options.
- Solaris support.
- All table lookup functions now use `none`.
- varargs: `fn foo(bar int, params ...string) {`.
@@ -351,8 +779,8 @@ this backend.
- `map.delete(key)`.
- `libcurl` dependency was removed from the `http` module.
- All function arguments are now immutable by default (previously they could be
modifed inside the function).
- `http` functions now return optionals.
modified inside the function).
- `http` functions now return options.
- `sync.WaitGroup`.
- `vweb` static files serving.
- `crypto.rand` module.
@@ -446,8 +874,8 @@ this backend.
## V 0.1.12
*4 Jul 2019*
- V can finally compile itself on Windows (https://github.com/vlang/v#mingw-w64).
- `os` module now uses optionals in all functions that return `File`.
- Lots of bugs with optionals were fixed.
- `os` module now uses options in all functions that return `File`.
- Lots of bugs with options were fixed.
- `println` was optimized. It no longer results in allocations.
Now it also works correctly with all integer types.
- Lots of `vfmt` fixes, it will be enabled tomorrow.

View File

@@ -1,7 +1,7 @@
## Code Structure
I tried to make the code of the compiler and vlib as simple and readable as
possible. One of V's goals is to be open to developers with different levels
possible. One of V's goals is to be open to developers with different levels
of experience in compiler development. Compilers don't need to be black boxes
full of magic that only few people understand.
@@ -24,52 +24,55 @@ The architecture of the compiler is very simple and has three distinct steps:
Parse/generate AST (`v.parser`) => Check types (`v.checker`)
=> Generate C/JavaScript/machine code (`v.gen`)
The main files are:
1. `cmd/v/v.v` The entry point.
- V figures out the build mode.
- Constructs the compiler object (`struct V`).
- Creates a list of .v files that need to be parsed.
- Creates a parser object for each file and runs `parse()` on them.
- The correct backend is called (C, JS, native), and a binary is compiled.
- V figures out the build mode.
- Constructs the compiler object (`struct V`).
- Creates a list of .v files that need to be parsed.
- Creates a parser object for each file and runs `parse()` on them.
- The correct backend is called (C, JS, native), and a binary is compiled.
2. `v/scanner` The scanner's job is to parse a list of characters and convert
them to tokens.
2. `vlib/v/scanner` The scanner's job is to parse a list of characters and convert
them to tokens.
3. `v/token` This is simply a list of all tokens, their string values, and a
couple of helper functions.
3. `vlib/v/token` This is simply a list of all tokens, their string values, and a
couple of helper functions.
4. `v/parser` The parser. It converts a list of tokens into an AST.
In V, objects can be used before declaration, so unknown types are marked as
unresolved. They are resolved later in the type checker.
4. `vlib/v/parser` The parser. It converts a list of tokens into an AST.
In V, objects can be used before declaration, so unknown types are marked as
unresolved. They are resolved later in the type checker.
5. `v/table` V creates one table object that is shared by all parsers. It
contains all types, consts, and functions, as well as several helpers to search
for objects by name, register new objects, modify types' fields, etc.
5. `vlib/v/table` V creates one table object that is shared by all parsers. It
contains all types, consts, and functions, as well as several helpers to search
for objects by name, register new objects, modify types' fields, etc.
6. `v/checker` Type checker and resolver. It processes the AST and makes sure
the types are correct. Unresolved types are resolved, type information is added
to the AST.
6. `vlib/v/checker` Type checker and resolver. It processes the AST and makes sure
the types are correct. Unresolved types are resolved, type information is added
to the AST.
7. `v/gen/c` C backend. It simply walks the AST and generates C code that can be
compiled with Clang, GCC, Visual Studio, and TCC.
7. `vlib/v/gen/c` C backend. It simply walks the AST and generates C code that can be
compiled with Clang, GCC, Visual Studio, and TCC.
8. `json.v` defines the json code generation. This file will be removed once V
supports comptime code generation, and it will be possible to do this using the
language's tools.
8. `vlib/v/gen/js` JavaScript backend. It simply walks the AST and generates JS code that can be
executed on the browser or in NodeJS/Deno.
9. `v/gen/native` is the directory with all the machine code generation logic. It
defines a set of functions that translate assembly instructions to machine code
and build the binary from scratch byte by byte. It manually builds all headers,
segments, sections, symtable, relocations, etc. Right now it only has basic
support of the native platform (ELF, MACHO format).
9. `vlib/v/gen/c/json.v` defines the json code generation. This file will be removed once V
supports comptime code generation, and it will be possible to do this using the
language's tools.
10. `vlib/v/gen/native` is the directory with all the machine code generation logic. It
defines a set of functions that translate assembly instructions to machine code
and build the binary from scratch byte by byte. It manually builds all headers,
segments, sections, symtable, relocations, etc. Right now it only has basic
support of the native platform (ELF, MACHO format).
The rest of the directories are vlib modules: `builtin/` (strings, arrays,
maps), `time/`, `os/`, etc. Their documentation is pretty clear.
## Example Workflow for Contributing
(provided by [@spytheman](https://github.com/spytheman))
(If you don't already have a GitHub account, please create one. Your GitHub
@@ -77,37 +80,40 @@ username will be referred to later as 'YOUR_GITHUB_USERNAME'. Change it
accordingly in the steps below.)
1. Fork https://github.com/vlang/v using GitHub's interface to your own account.
Let's say that the forked repository is at
`https://github.com/YOUR_GITHUB_USERNAME/v` .
Let's say that the forked repository is at
`https://github.com/YOUR_GITHUB_USERNAME/v` .
2. Clone the main v repository https://github.com/vlang/v to a local folder on
your computer, say named nv/ (`git clone https://github.com/vlang/v nv`)
your computer, say named nv/ (`git clone https://github.com/vlang/v nv`)
3. `cd nv`
4. `git remote add pullrequest https://github.com/YOUR_GITHUB_USERNAME/v`
NB: the remote named `pullrequest` should point to YOUR own forked repo, not the
main v repository! After this, your local cloned repository is prepared for
making pullrequests, and you can just do normal git operations such as:
`git pull` `git status` and so on.
Note: The remote named `pullrequest` should point to YOUR own forked repo, not the
main v repository! After this, your local cloned repository is prepared for
making pull requests, and you can just do normal git operations such as:
`git pull` `git status` and so on.
5. When finished with a feature/bugfix/change, you can:
`git checkout -b fix_alabala`
6. `git push pullrequest` # (NOTE: the `pullrequest` remote was setup on step 4)
- Don't forget to keep formatting standards, run `v fmt -w YOUR_MODIFIED_FILES` before committing
6. `git push pullrequest` Note: The `pullrequest` remote was setup on step 4
7. On GitHub's web interface, go to: https://github.com/vlang/v/pulls
Here the UI shows a dialog with a button to make a new pull request based on
the new pushed branch.
(Example dialog: https://url4e.com/gyazo/images/364edc04.png)
8. After making your pullrequest (aka, PR), you can continue to work on the
branch `fix_alabala` ... just do again `git push pullrequest` when you have more
commits.
8. After making your pull request (aka, PR), you can continue to work on the
branch `fix_alabala` ... just do again `git push pullrequest` when you have more
commits.
9. If there are merge conflicts, or a branch lags too much behind V's master,
you can do the following:
you can do the following:
1. `git pull --rebase origin master` # solve conflicts and do
`git rebase --continue`
2. `git push pullrequest -f` # this will overwrite your current remote branch
with the updated version of your changes.
1. `git pull --rebase origin master` # solve conflicts and do
`git rebase --continue`
2. `git push pullrequest -f` # this will overwrite your current remote branch
with the updated version of your changes.
The point of doing the above steps, is to never directly push to the main V
repository, *only to your own fork*. Since your local `master` branch tracks the
@@ -116,7 +122,8 @@ main V repository's master, then `git checkout master`, as well as
(these are actually used by `v up`) and git can always do it cleanly.
Git is very flexible, so there are other ways to accomplish the same thing.
See the [GitHub flow](https://guides.github.com/introduction/git-handbook/#github), for more information.
See the [GitHub flow](https://guides.github.com/introduction/git-handbook/#github), for more
information.
## Using Github's hub CLI tool
@@ -125,9 +132,11 @@ You can download the `hub` tool from https://hub.github.com/ . Using
to make PRs. Most remote operations can be done through the `hub` CLI
command.
NB: You still need to have a GitHub account.
> **Note**
> You still need to have a GitHub account.
### Preparation:
(steps 1..3 need to be done just *once*):
1. `hub clone vlang/v my_v`
@@ -135,13 +144,14 @@ NB: You still need to have a GitHub account.
3. `hub fork --remote-name pullrequest`
4. `git checkout -b my_cool_feature` # Step 4 is better done *once per each new
feature/bugfix* that you make.
feature/bugfix* that you make.
### Improve V by making commits:
5. `git commit -am "math: add a new function copysign"`
### Testing your commits locally:
You can test locally whether your changes have not broken something by
running: `v test-all`. See `TESTS.md` for more details.
@@ -150,6 +160,7 @@ running: `v test-all`. See `TESTS.md` for more details.
6. `git push pullrequest`
### Making a PR with `hub`:
(so that your changes can be merged to the main V repository)
7. `hub pull-request`
@@ -159,6 +170,7 @@ Optionally, you can track the status of your PR CI tests with:
8. `hub ci-status --verbose`
### Fixing failing tests:
If everything is OK, after 5-10 minutes, the CI tests should pass for
all platforms. If not, visit the URLs for the failing CI jobs, see
which tests have failed and then fix them by making more changes. Just use
@@ -181,22 +193,22 @@ not the program, so do for example: `v -d time_parsing cmd/v` or
Some flags can make the compiler very verbose, so it is recommended
to create a copy of the compiler rather than replacing it with `v self`.
| Flag | Usage |
|------|-------|
| `debugscanner` | Prints debug information during the scanning phase |
| `debug_codegen` | Prints automatically generated V code during the scanning phase |
| `debug_interface_table` | Prints generated interfaces during C generation |
| `debug_interface_type_implements` | Prints debug information when checking that a type implements in interface |
| `debug_embed_file_in_prod` | Prints debug information about the embedded files with `$embed_file('somefile')` |
| `print_vweb_template_expansions` | Prints vweb compiled HTML files |
| `time_checking` | Prints the time spent checking files and other related information |
| `time_parsing` | Prints the time spent parsing files and other related information |
| `trace_autofree` | Prints details about how/when -autofree puts free() calls |
| `trace_autostr` | Prints details about `.str()` method auto-generated by the compiler during C generation |
| `trace_ccoptions` | Prints options passed down to the C compiler |
| `trace_checker` | Prints details about the statements being checked |
| `trace_gen` | Prints strings written to the generated C file. Beware, this flag is very verbose |
| `trace_parser` | Prints details about parsed statements and expressions |
| `trace_thirdparty_obj_files` | Prints details about built thirdparty obj files |
| `trace_usecache` | Prints details when -usecache is used |
| `trace_embed_file` | Prints details when $embed_file is used |
| Flag | Usage |
|-----------------------------------|---------------------------------------------------------------------------------------------------------------------|
| `debugscanner` | Prints debug information during the scanning phase |
| `debug_codegen` | Prints automatically generated V code during the scanning phase |
| `debug_interface_table` | Prints generated interfaces during C generation |
| `debug_interface_type_implements` | Prints debug information when checking that a type implements in interface |
| `print_vweb_template_expansions` | Prints vweb compiled HTML files |
| `time_checking` | Prints the time spent checking files and other related information |
| `time_parsing` | Prints the time spent parsing files and other related information |
| `trace_autofree` | Prints details about how/when -autofree puts free() calls |
| `trace_autostr` | Prints details about `.str()` method auto-generated by the compiler during C generation |
| `trace_ccoptions` | Prints options passed down to the C compiler |
| `trace_checker` | Prints details about the statements being checked |
| `trace_gen` | Prints strings written to the generated C file. Beware, this flag is very verbose |
| `trace_parser` | Prints details about parsed statements and expressions |
| `trace_thirdparty_obj_files` | Prints details about built thirdparty obj files |
| `trace_usecache` | Prints details when -usecache is used |
| `trace_embed_file` | Prints details when $embed_file is used |
| `embed_only_metadata` | Embed only the metadata for the file(s) with `$embed_file('somefile')`; faster; for development, *not* distribution |

View File

@@ -7,7 +7,7 @@ WORKDIR /opt/vlang
ARG USE_LOCAL
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends gcc clang make git && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends gcc clang make git binutils && \
apt-get clean && rm -rf /var/cache/apt/archives/* && \
rm -rf /var/lib/apt/lists/*

View File

@@ -12,11 +12,14 @@ RUN mkdir -p /opt/vlang && ln -s /opt/vlang/v /usr/bin/v
ARG USE_LOCAL
## libexecinfo is needed for the bundled tcc
RUN apk --no-cache add \
git make upx gcc bash \
musl-dev \
musl-dev libc-dev \
openssl-dev sqlite-dev \
libx11-dev glfw-dev freetype-dev
libx11-dev glfw-dev freetype-dev \
libexecinfo-dev libexecinfo-static \
libc6-compat gcompat binutils
## RUN apk --no-cache add --virtual sdl2deps sdl2-dev sdl2_ttf-dev sdl2_mixer-dev sdl2_image-dev
COPY . /vlang-local

View File

@@ -1,10 +1,10 @@
FROM mstorsjo/llvm-mingw
LABEL maintainer="Vitaly Takmazov <vitalyster@gmail.com>"
LABEL maintainer="Delyan Angelov <delian66@gmail.com>"
COPY . .
RUN make
RUN ./v -os windows -o v.c cmd/v
RUN x86_64-w64-mingw32-gcc v.c -std=c99 -I ./thirdparty/stdatomic/win -w -municode -o v.exe
RUN x86_64-w64-mingw32-gcc v.c -std=c99 -w -municode -o v.exe
RUN file v.exe
CMD [ "bash" ]

View File

@@ -4,16 +4,19 @@ LDFLAGS ?=
TMPDIR ?= /tmp
VROOT ?= .
VC ?= ./vc
V ?= ./v
VEXE ?= ./v
VCREPO ?= https://github.com/vlang/vc
TCCREPO ?= https://github.com/vlang/tccbin
LEGACYREPO ?= https://github.com/macports/macports-legacy-support
VCFILE := v.c
TMPTCC := $(VROOT)/thirdparty/tcc
LEGACYLIBS := $(VROOT)/thirdparty/legacy
TMPLEGACY := $(LEGACYLIBS)/source
TCCOS := unknown
TCCARCH := unknown
GITCLEANPULL := git clean -xf && git pull --quiet
GITFASTCLONE := git clone --depth 1 --quiet --single-branch
GITFASTCLONE := git clone --filter=blob:none --quiet
#### Platform detections and overrides:
_SYS := $(shell uname 2>/dev/null || echo Unknown)
@@ -22,17 +25,23 @@ _SYS := $(patsubst MINGW%,MinGW,$(_SYS))
ifneq ($(filter $(_SYS),MSYS MinGW),)
WIN32 := 1
V:=./v.exe
VEXE := ./v.exe
endif
ifeq ($(_SYS),Linux)
LINUX := 1
TCCOS := linux
ifneq ($(shell ldd /bin/ls | grep musl),)
TCCOS := linuxmusl
endif
endif
ifeq ($(_SYS),Darwin)
MAC := 1
TCCOS := macos
ifeq ($(shell expr $(shell uname -r | cut -d. -f1) \<= 15), 1)
LEGACY := 1
endif
endif
ifeq ($(_SYS),FreeBSD)
@@ -45,6 +54,11 @@ TCCOS := netbsd
LDFLAGS += -lexecinfo
endif
ifeq ($(_SYS),OpenBSD)
TCCOS := openbsd
LDFLAGS += -lexecinfo
endif
ifdef ANDROID_ROOT
ANDROID := 1
undefine LINUX
@@ -76,33 +90,42 @@ endif
endif
endif
.PHONY: all clean fresh_vc fresh_tcc check_for_working_tcc
.PHONY: all clean rebuild check fresh_vc fresh_tcc fresh_legacy check_for_working_tcc
ifdef prod
VFLAGS+=-prod
endif
all: latest_vc latest_tcc
all: latest_vc latest_tcc latest_legacy
ifdef WIN32
$(CC) $(CFLAGS) -std=c99 -municode -w -I ./thirdparty/stdatomic/nix -o v1.exe $(VC)/$(VCFILE) $(LDFLAGS)
$(CC) $(CFLAGS) -std=c99 -municode -w -o v1.exe $(VC)/$(VCFILE) $(LDFLAGS)
v1.exe -no-parallel -o v2.exe $(VFLAGS) cmd/v
v2.exe -o $(V) $(VFLAGS) cmd/v
v2.exe -o $(VEXE) $(VFLAGS) cmd/v
del v1.exe
del v2.exe
else
$(CC) $(CFLAGS) -std=gnu99 -w -I ./thirdparty/stdatomic/nix -o v1.exe $(VC)/$(VCFILE) -lm -lpthread $(LDFLAGS)
ifdef LEGACY
$(MAKE) -C $(TMPLEGACY)
$(MAKE) -C $(TMPLEGACY) PREFIX=$(realpath $(LEGACYLIBS)) CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) install
rm -rf $(TMPLEGACY)
$(eval override LDFLAGS+=-L$(realpath $(LEGACYLIBS))/lib -lMacportsLegacySupport)
endif
$(CC) $(CFLAGS) -std=gnu99 -w -o v1.exe $(VC)/$(VCFILE) -lm -lpthread $(LDFLAGS)
./v1.exe -no-parallel -o v2.exe $(VFLAGS) cmd/v
./v2.exe -o $(V) $(VFLAGS) cmd/v
./v2.exe -nocache -o $(VEXE) $(VFLAGS) cmd/v
rm -rf v1.exe v2.exe
endif
@$(V) run cmd/tools/detect_tcc.v
@$(VEXE) run cmd/tools/detect_tcc.v
@echo "V has been successfully built"
@$(V) -version
@$(VEXE) -version
clean:
rm -rf $(TMPTCC)
rm -rf $(LEGACYLIBS)
rm -rf $(VC)
rebuild: clean all
ifndef local
latest_vc: $(VC)/.git/config
cd $(VC) && $(GITCLEANPULL)
@@ -113,7 +136,7 @@ endif
check_for_working_tcc:
@$(TMPTCC)/tcc.exe --version > /dev/null 2> /dev/null || echo "The executable '$(TMPTCC)/tcc.exe' does not work."
fresh_vc:
rm -rf $(VC)
$(GITFASTCLONE) $(VCREPO) $(VC)
@@ -145,22 +168,45 @@ else
@$(MAKE) --quiet check_for_working_tcc 2> /dev/null
endif
ifndef local
latest_legacy: $(TMPLEGACY)/.git/config
ifdef LEGACY
cd $(TMPLEGACY) && $(GITCLEANPULL)
endif
else
latest_legacy:
ifdef LEGACY
@echo "Using local legacysupport"
endif
endif
fresh_legacy:
rm -rf $(LEGACYLIBS)
$(GITFASTCLONE) $(LEGACYREPO) $(TMPLEGACY)
$(TMPTCC)/.git/config:
$(MAKE) fresh_tcc
$(VC)/.git/config:
$(MAKE) fresh_vc
$(TMPLEGACY)/.git/config:
ifdef LEGACY
$(MAKE) fresh_legacy
endif
asan:
$(MAKE) all CFLAGS='-fsanitize=address,undefined'
selfcompile:
$(V) -cg -o v cmd/v
$(VEXE) -cg -o v cmd/v
selfcompile-static:
$(V) -cg -cflags '--static' -o v-static cmd/v
$(VEXE) -cg -cflags '--static' -o v-static cmd/v
### NB: Please keep this Makefile and make.bat simple.
install:
@echo 'Please use `sudo ./v symlink` instead.'
check:
$(VEXE) test-all

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019-2021 Alexander Medvednikov
Copyright (c) 2019-2023 Alexander Medvednikov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,12 +1,22 @@
CC ?= cc
VFLAGS ?=
CFLAGS ?=
LDFLAGS ?=
all:
rm -rf vc/
git clone --depth 1 --quiet https://github.com/vlang/vc
$(CC) -std=gnu11 -w -I ./thirdparty/stdatomic/nix -o v1 vc/v.c -lm -lexecinfo -lpthread
.PHONY: all check download_vc v
all: download_vc v
download_vc:
if [ -f vc/v.c ] ; then git -C vc/ pull; else git clone --filter=blob:none https://github.com/vlang/vc vc/; fi
v:
$(CC) $(CFLAGS) -std=gnu11 -w -o v1 vc/v.c -lm -lexecinfo -lpthread $(LDFLAGS)
./v1 -no-parallel -o v2 $(VFLAGS) cmd/v
./v2 -o v $(VFLAGS) cmd/v
rm -rf v1 v2 vc/
rm -rf v1 v2
@echo "V has been successfully built"
./v run ./cmd/tools/detect_tcc.v
check:
./v test-all

257
README.md
View File

@@ -1,39 +1,37 @@
<div align="center">
<div align="center" style="display:grid;place-items:center;">
<p>
<img width="80" src="https://raw.githubusercontent.com/vlang/v-logo/master/dist/v-logo.svg?sanitize=true">
<a href="https://vlang.io/" target="_blank"><img width="80" src="https://raw.githubusercontent.com/vlang/v-logo/master/dist/v-logo.svg?sanitize=true" alt="V logo"></a>
</p>
<h1>The V Programming Language</h1>
[vlang.io](https://vlang.io) |
[Docs](https://github.com/vlang/v/blob/master/doc/docs.md) |
[Changelog](https://github.com/vlang/v/blob/master/CHANGELOG.md) |
[Speed](https://fast.vlang.io/) |
[Contributing & compiler design](https://github.com/vlang/v/blob/master/CONTRIBUTING.md)
[vlang.io](https://vlang.io) | [Docs](https://github.com/vlang/v/blob/master/doc/docs.md) | [Changelog](https://github.com/vlang/v/blob/master/CHANGELOG.md) | [Speed](https://fast.vlang.io/) | [Contributing & compiler design](https://github.com/vlang/v/blob/master/CONTRIBUTING.md)
</div>
<div align="center">
<div align="center" style="display:grid;place-items:center;">
<!--
[![Build Status][WorkflowBadge]][WorkflowUrl]
-->
[![Sponsor][SponsorBadge]][SponsorUrl]
[![Patreon][PatreonBadge]][PatreonUrl]
[![Discord][DiscordBadge]][DiscordUrl]
[![Twitter][TwitterUrl]][TwitterBadge]
[![Twitter][TwitterBadge]][TwitterUrl]
[![Modules][ModulesBadge]][ModulesUrl]
</div>
## Key Features of V
- Simplicity: the language can be learned in less than an hour
- Simplicity: the language can be learned over the course of a weekend
- Fast compilation: ≈110k loc/s with a Clang backend,
1 million loc/s with native and tcc backends *(Intel i5-7500, SSD, no optimization)* ([demo video](https://www.youtube.com/watch?v=pvP6wmcl_Sc))
500k loc/s with native and tcc backends *(Intel i5-7500, SSD, no
optimization)* ([demo video](https://www.youtube.com/watch?v=pvP6wmcl_Sc))
- Easy to develop: V compiles itself in less than a second
- Performance: as fast as C (V's main backend compiles to human-readable C)
- Safety: no null, no globals, no undefined behavior, immutability by default
- C to V translation
- Safety: no null, no globals, no undefined behavior (wip), immutability by default
- C to V translation ([Translating DOOM demo video](https://www.youtube.com/watch?v=6oXrz3oRoEg))
- Hot code reloading
- [Innovative memory management](https://vlang.io/#memory) ([demo video](https://www.youtube.com/watch?v=gmB8ea8uLsM))
- [Flexible memory management](https://vlang.io/#memory). GC by default, manual via `v -gc none`,
arena allocation via `v -prealloc`, autofree via `v -autofree`
([autofree demo video](https://www.youtube.com/watch?v=gmB8ea8uLsM)).
- [Cross-platform UI library](https://github.com/vlang/ui)
- Built-in graphics library
- Easy cross-compilation
@@ -62,20 +60,32 @@ language, very similar to the way it is right now.
## Installing V from source
### Linux, macOS, Windows, *BSD, Solaris, WSL, Android, Raspbian
--> **_(this is the preferred method)_**
### Linux, macOS, Windows, *BSD, Solaris, WSL, etc.
Usually, installing V is quite simple if you have an environment that already has a
functional `git` installation.
To get started, simply try to execute the following in your terminal/shell:
```bash
git clone https://github.com/vlang/v
cd v
make
# HINT: Using Windows? run make.bat in a cmd shell, or ./make.bat in PowerShell
```
That's it! Now you have a V executable at `[path to V repo]/v`.
That should be it and you should find your V executable at `[path to V repo]/v`.
`[path to V repo]` can be anywhere.
(On Windows `make` means running `make.bat`, so make sure you use `cmd.exe`)
(As in the hint above, on Windows `make` means running `make.bat`.)
Now you can try `./v run examples/hello_world.v` (`v.exe` on Windows).
Now you can try `./v run examples/hello_world.v` (or `v run examples/hello_world.v` in cmd shell).
* *Trouble? Please see the note above and link to
[Installation Issues](https://github.com/vlang/v/discussions/categories/installation-issues)
for help.*
V is constantly being updated. To update V, simply run:
@@ -83,10 +93,25 @@ V is constantly being updated. To update V, simply run:
v up
```
> **Note**
> If you run into any trouble, or you have a different operating
> system or Linux distribution that doesn't install or work immediately, please see
> [Installation Issues](https://github.com/vlang/v/discussions/categories/installation-issues)
> and search for your OS and problem.
>
> If you can't find your problem, please add it to an existing discussion if one exists for
> your OS, or create a new one if a main discussion doesn't yet exist for your OS.
### C compiler
It's recommended to use Clang, GCC, or Visual Studio.
If you are doing development, you most likely already have one of those installed.
The [Tiny C Compiler (tcc)](https://repo.or.cz/w/tinycc.git) is downloaded for you by `make` if
there is a compatible version for your system, and installed under the V `thirdparty` directory.
This compiler is very fast, but does almost no optimizations. It is best for development builds.
For production builds (using the `-prod` option to V), it's recommended to use clang, gcc, or
Microsoft Visual C++. If you are doing development, you most likely already have one of those
installed.
Otherwise, follow these instructions:
@@ -94,15 +119,12 @@ Otherwise, follow these instructions:
- [Installing a C compiler on Windows](https://github.com/vlang/v/wiki/Installing-a-C-compiler-on-Windows)
However, if none is found when running `make` on Linux or Windows,
TCC is downloaded as the default C backend.
It's very lightweight (several MB) so this shouldn't take too long.
### Symlinking
NB: it is *highly recommended*, that you put V on your PATH. That saves
you the effort to type in the full path to your v executable every time.
V provides a convenience `v symlink` command to do that more easily.
> **Note**
> It is *highly recommended*, that you put V on your PATH. That saves
> you the effort to type in the full path to your v executable every time.
> V provides a convenience `v symlink` command to do that more easily.
On Unix systems, it creates a `/usr/local/bin/v` symlink to your
executable. To do that, run:
@@ -111,23 +133,38 @@ executable. To do that, run:
sudo ./v symlink
```
On Windows, start a new shell with administrative privileges, for
example by <kbd>Windows Key</kbd>, then type `cmd.exe`, right-click on its menu
entry, and choose `Run as administrator`. In the new administrative
shell, cd to the path, where you have compiled v.exe, then type:
On Windows, start a new shell with administrative privileges, for example by pressing the
<kbd>Windows Key</kbd>, then type `cmd.exe`, right-click on its menu entry, and choose `Run as
administrator`. In the new administrative shell, cd to the path where you have compiled V, then
type:
```bat
.\v.exe symlink
v symlink
```
That will make V available everywhere, by adding it to your PATH.
Please restart your shell/editor after that, so that it can pick
the new PATH variable.
(or `./v symlink` in PowerShell)
NB: there is no need to run `v symlink` more than once - v will
continue to be available, even after `v up`, restarts, and so on.
You only need to run it again, if you decide to move the V repo
folder somewhere else.
That will make V available everywhere, by adding it to your PATH. Please restart your
shell/editor after that, so that it can pick up the new PATH variable.
> **Note**
> There is no need to run `v symlink` more than once - v will still be available, even after
> `v up`, restarts, and so on. You only need to run it again if you decide to move the V repo
> folder somewhere else.
### Void Linux
<details><summary>Expand Void Linux instructions</summary>
```bash
# xbps-install -Su base-devel
# xbps-install libatomic-devel
$ git clone https://github.com/vlang/v
$ cd v
$ make
```
</details>
### Docker
@@ -151,17 +188,55 @@ docker run --rm -it vlang:latest
</details>
### Testing and running the examples
### Termux/Android
On Termux, V needs some packages preinstalled - a working C compiler, also `libexecinfo`,
`libgc` and `libgc-static`. After installing them, you can use the same script, like on
Linux/macos:
```bash
pkg install clang libexecinfo libgc libgc-static make git
git clone https://github.com/vlang/v
cd v
make
```
## Installing editor/IDE plugin
V has plugins for many editors:
- [VS Code plugin](https://github.com/vlang/vscode-vlang)
- [JetBrains IDE plugin](https://plugins.jetbrains.com/plugin/20287-vlang/docs/quick-start-guide.html)
- [Vim plugins](https://github.com/vlang/awesome-v#vim)
- [Emacs plugins](https://github.com/vlang/awesome-v#emacs)
- [Sublime Text 3 plugins](https://github.com/vlang/awesome-v#sublime-text-3)
- [Atom plugins](https://github.com/vlang/awesome-v#atom)
### IntelliSense
V has a Language Server:
[VLS](https://github.com/vlang/vls).
The VS Code plugin provides built-in support for VLS.
> **Note**
>
> VLS may be unstable at the moment.
> If you encounter any problem, please create a new
> [issue](https://github.com/vlang/vls/issues).
The plugin for JetBrains IDE (IntelliJ, CLion, GoLand, etc) at the moment is
the best choice if you want a great V development experience.
You can see all its features in
[its documentation](https://plugins.jetbrains.com/plugin/20287-vlang/docs/syntax-highlighting.html).
## Testing and running the examples
Make sure V can compile itself:
```bash
v self
```
```bash
$ v self
$ v
V 0.2.x
V 0.3.x
Use Ctrl-C or `exit` to exit
>>> println('hello world')
@@ -179,47 +254,52 @@ v run news_fetcher.v
v run tetris/tetris.v
```
<img src='https://raw.githubusercontent.com/vlang/v/master/examples/tetris/screenshot.png' width=300>
<img src='https://raw.githubusercontent.com/vlang/v/master/examples/tetris/screenshot.png' width=300 alt='tetris screenshot'>
NB: In order to build Tetris or 2048 (or anything else using `sokol` or `gg` graphics modules)
on some Linux systems, you need to install `libxi-dev` and `libxcursor-dev` .
In order to build Tetris or 2048 (or anything else using `sokol` or `gg` graphics modules),
you will need additional development libraries for your system.
| System | Installation method |
|---------------------|----------------------------------------------------------------------------------------------------|
| Debian/Ubuntu based | `sudo apt install libxi-dev libxcursor-dev libgl-dev` |
| Fedora/RH/CentOS | `sudo dnf install libXcursor-devel libXi-devel libX11-devel libglvnd-devel` |
| NixOS | add `xorg.libX11.dev xorg.libXcursor.dev xorg.libXi.dev libGL.dev` to `environment.systemPackages` |
## V net.http, net.websocket, `v install`
If you plan to use the net.http module, or the net.websocket module, you also need to install
OpenSSL on non-Windows systems:
```bash
macOS:
brew install openssl
The net.http module, the net.websocket module, and the `v install` command may all use SSL.
V comes with a version of mbedtls, which should work on all systems. If you find a need to
use OpenSSL instead, you will need to make sure that it is installed on your system, then
use the `-d use_openssl` switch when you compile.
Debian/Ubuntu:
sudo apt install libssl-dev
To install OpenSSL on non-Windows systems:
Arch/Manjaro:
openssl is installed by default
| System | Installation command |
|---------------------|----------------------------------|
| macOS | `brew install openssl` |
| Debian/Ubuntu based | `sudo apt install libssl-dev` |
| Arch/Manjaro | openssl is installed by default |
| Fedora/CentOS/RH | `sudo dnf install openssl-devel` |
Fedora:
sudo dnf install openssl-devel
```
On Windows, OpenSSL is simply hard to get working correctly. The instructions
[here](https://tecadmin.net/install-openssl-on-windows/) may (or may not) help.
## V sync
V's `sync` module and channel implementation uses libatomic.
It is most likely already installed on your system, but if not,
you can install it, by doing the following:
```bash
MacOS: already installed
Debian/Ubuntu:
sudo apt install libatomic1
Fedora/CentOS/RH:
sudo dnf install libatomic-static
```
| System | Installation command |
|---------------------|-------------------------------------|
| macOS | already installed |
| Debian/Ubuntu based | `sudo apt install libatomic1` |
| Fedora/CentOS/RH | `sudo dnf install libatomic-static` |
## V UI
<a href="https://github.com/vlang/ui">
<img src='https://raw.githubusercontent.com/vlang/ui/master/examples/screenshot.png' width=712>
<img src='https://raw.githubusercontent.com/vlang/ui/master/examples/screenshot.png' width=712 alt='V UI example screenshot'>
</a>
https://github.com/vlang/ui
@@ -254,17 +334,17 @@ With V's `vab` tool, building V UI and graphical apps for Android can become as
```
[https://github.com/vlang/vab](https://github.com/vlang/vab).
<img src="https://user-images.githubusercontent.com/768942/107622846-c13f3900-6c58-11eb-8a66-55db12979b73.png">
<img src="https://user-images.githubusercontent.com/768942/107622846-c13f3900-6c58-11eb-8a66-55db12979b73.png" alt="vab examples screenshot">
## Developing web applications
Check out the [Building a simple web blog](https://github.com/vlang/v/blob/master/tutorials/building_a_simple_web_blog_with_vweb/README.md)
Check out the
[Building a simple web blog](https://github.com/vlang/v/blob/master/tutorials/building_a_simple_web_blog_with_vweb/README.md)
tutorial and Gitly, a light and fast alternative to GitHub/GitLab:
https://github.com/vlang/gitly
<img src="https://user-images.githubusercontent.com/687996/85933714-b195fe80-b8da-11ea-9ddd-09cadc2103e4.png">
<img src="https://user-images.githubusercontent.com/687996/85933714-b195fe80-b8da-11ea-9ddd-09cadc2103e4.png" alt="gitly screenshot">
## Vinix, an OS/kernel written in V
@@ -273,20 +353,35 @@ Vinix is an OS/kernel that already runs bash, GCC, V, and nano.
https://github.com/vlang/vinix
<img src="https://github.com/vlang/vinix/raw/main/screenshot.png?raw=true">
<img src="https://github.com/vlang/vinix/blob/main/screenshot0.png?raw=true" alt="vinix screenshot 1">
<img src="https://github.com/vlang/vinix/blob/main/screenshot1.png?raw=true" alt="vinix screenshot 2">
## Acknowledgement
V thanks Fabrice Bellard for his original work on the
[TCC - Tiny C Compiler](https://bellard.org/tcc/).
Note the TCC website is old; the current TCC repository can be found
[here](https://repo.or.cz/w/tinycc.git).
V utilizes pre-built TCC binaries located at
[https://github.com/vlang/tccbin/](https://github.com/vlang/tccbin/).
## Troubleshooting
Please see the [Troubleshooting](https://github.com/vlang/v/wiki/Troubleshooting) section on our [wiki page](https://github.com/vlang/v/wiki)
Please see the
[Troubleshooting](https://github.com/vlang/v/wiki/Troubleshooting)
section on our
[wiki page](https://github.com/vlang/v/wiki).
[WorkflowBadge]: https://github.com/vlang/v/workflows/CI/badge.svg
[DiscordBadge]: https://img.shields.io/discord/592103645835821068?label=Discord&logo=discord&logoColor=white
[PatreonBadge]: https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Dvlang%26type%3Dpledges
[PatreonBadge]: https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Dvlang%26type%3Dpatrons&style=flat
[SponsorBadge]: https://camo.githubusercontent.com/da8bc40db5ed31e4b12660245535b5db67aa03ce/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d53706f6e736f72266d6573736167653d254532253944254134266c6f676f3d476974487562
[TwitterBadge]: https://twitter.com/v_language
[TwitterBadge]: https://img.shields.io/badge/follow-%40v_language-1DA1F2?logo=twitter&style=flat&logoColor=white&color=1da1f2
[ModulesBadge]: https://img.shields.io/badge/modules-reference-027d9c?logo=v&logoColor=white&logoWidth=10
[WorkflowUrl]: https://github.com/vlang/v/commits/master
[DiscordUrl]: https://discord.gg/vlang
[PatreonUrl]: https://patreon.com/vlang
[SponsorUrl]: https://github.com/sponsors/medvednikov
[TwitterUrl]: https://img.shields.io/twitter/follow/v_language.svg?style=flatl&label=Follow&logo=twitter&logoColor=white&color=1da1f2
[TwitterUrl]: https://twitter.com/v_language
[ModulesUrl]: https://modules.vlang.io

View File

@@ -1,34 +1,67 @@
## [Version 0.3](https://github.com/vlang/v/projects/5)
- [ ] [make `-autofree` the default](https://github.com/vlang/v/issues/6989)
- [x] [gc option]
- [ ] [coroutines](https://github.com/vlang/v/issues/561)
## [Version 0.3]
- [x] gc option
- [x] channels
- [x] lock{}
- [x] thread safe arrays
- [ ] [thread safe maps](https://github.com/vlang/v/issues/6992)
- [ ] [C2V translator](https://github.com/vlang/v/issues/6985)
- [ ] doom.v
- [x] rune type
- [x] replace `ustring` with `[]rune`
- [x] fix `byte.str()`
- [x] maps with non-string keys
- [x] iOS/Android support
- [ ] parallel parser
- [ ] parallel checker
- [x] parallel cgen
- [ ] parallel C compilation
- [ ] `recover()` from panics
- [x] IO streams
- [x] struct embedding
- [x] interface embedding
- [x] interfaces: allow struct fields (not just methods)
- [ ] vfmt: fix common errors automatically (make vars mutable and vice versa, add missing imports)
- [ ] method expressions with an explicit receiver as the first argument
- [x] short generics syntax (`foo(5)` instead of `foo<int>(5)`)
- [ ] fix all remaining generics issues
- [ ] merge v.c and v_win.c
- [x] more advanced errors, not just `error('message')`
- [ ] VLS for autocomplete, refactoring, go to definition etc
- [ ] Recursive structs via optionals: `struct Node { next ?Node }`
- [ ] Remove `foo = 0` for `&Foo`
## [Version 0.4]
- [x] [Coroutines](https://github.com/vlang/v/discussions/11582)
- [x] vfmt: add missing imports (like goimports)
- [x] Recursive structs via options: `struct Node { next ?Node }`
- [x] First class Option type
- [x] Optional function struct fields
- [ ] Handle function pointers safely, remove `if function == 0 {`
- [x] Bundle OpenSSL like GC
- [x] Anonymous structs
- [x] Improve vweb: allow separation of logic via "controllers", lots of other fixes
- [x] New VPM site
## [Version 0.5]
- [ ] [Thread safe maps](https://github.com/vlang/v/discussions/11729)
- [ ] Parallel parser
- [ ] Parallel checker
- [ ] Parallel C compilation
- [ ] `recover()` from panics
- [ ] -usecache on by default
- [ ] -skip-unused on by default
- [ ] 64/32 bit int depending on arch (will remove array.len limitation on 64 bit systems)
- [ ] `copy()` builtin function (e.g. for easier conversion from `[]Foo` to `[4]Foo`)
## [Version 1.0]
- [ ] Cross compilation of C
- [ ] Big remaining bugs fixed
- [ ] More powerful comptime
- [ ] Constraits for generics
- [ ] Coroutines on Windows
- [ ] Autofree memory management option ready for production
- [ ] C2V supporting entire C99 standard
### Tooling
- [ ] More stable VLS
- [ ] Profiler improvements
- [ ] Basic interactive shell with search, sort, filter, etc.
- [ ] VPM
- [x] New VPM site
- [ ] Package versioning
- [ ] A better documentation platform
### Web
- [ ] Site that brings everything together in a single style
- [ ] Interactive educational platform (learning to program for beginners)

View File

@@ -5,15 +5,16 @@ and before submitting PRs.
Tip: use `v -cc tcc` when compiling tests, because TCC is much faster,
compared to most other C compilers like clang/gcc/msvc. Most test commands
will use the V compiler and the V tools many times, potentially
will use the V compiler and the V tools many times, potentially
hundreds/thousands of times.
## `v test-all`
Test and build *everything*. Usefull to verify *locally*, that the CI will
Test and build *everything*. Useful to verify *locally*, that the CI will
most likely pass. Slowest, but most comprehensive.
It works, by running these in succession:
* `v test-cleancode`
* `v test-self`
* `v test-fmt`
@@ -23,10 +24,12 @@ It works, by running these in succession:
* `v install nedpals.args`
# Details:
In the `v` repo there are many tests. The main types are:
## `_test.v` tests - these are the normal V test files.
All `test_` functions in these files, will be ran automatically by
All `test_` functions in these files, will be ran automatically by
V's test framework.
NB 1: You can run test files one by one, with:
@@ -44,22 +47,22 @@ recursively.
`v -stats test folder` - same, but will also produce timing reports
about how fast each test_ function in each _test.v file ran.
## `v test vlib/v/tests`:
This folder contains _test.v files, testing the different features of the V
compiler. Each of them will be compiled, and all the features in them have
to work (verified by assertions).
## `v vlib/v/tests/inout/compiler_test.v`
## `v vlib/v/slow_tests/inout/compiler_test.v`
This is a *test runner*, that checks whether the output of running a V program,
matches an expected .out file. You can also check for code that does panic
using this test runner - just paste the start of the `panic()` output in the
corresponding .out file.
NB: these tests, expect to find a pair of `.vv` and `.out` files, in the folder:
vlib/v/tests/inout
> **Note**
> These tests, expect to find a pair of `.vv` and `.out` files, in the folder:
> vlib/v/slow_tests/inout
The test runner will run each `.vv` file, and will check that its output, matches
the contents of the `.out` file with the same base name. This is particularly useful
@@ -77,11 +80,27 @@ Each `.c.must_have` file, consists of multiple lines. Each of these
lines, *should* be present *at least once* in the output, when the .vv
file is compiled with `-o -` .
## `v vlib/v/tests/run_project_folders_test.v`
## `v vlib/v/slow_tests/run_project_folders_test.v`
This *test runner*, checks whether whole project folders, can be compiled, and run.
NB: Each project in these folders, should finish with an exit code of 0,
and it should output `OK` as its last stdout line.
> **Note**
> Each project in these folders, should finish with an exit code of 0,
> and it should output `OK` as its last stdout line.
## `v vlib/v/tests/known_errors/known_errors_test.v`
This *test runner*, checks whether a known program, that was expected to compile,
but did NOT, due to a buggy checker, parser or cgen, continues to fail.
The negative programs are collected in the `vlib/v/tests/known_errors/testdata/` folder.
Each of them should FAIL to compile, due to a known/confirmed compiler bug/limitation.
The intended use of this, is for providing samples, that currently do NOT compile,
but that a future compiler improvement WILL be able to compile, and to
track, whether they were not fixed incidentally, due to an unrelated
change/improvement. For example, code that triggers generating invalid C code can go here,
and later when a bug is fixed, can be moved to a proper _test.v or .vv/.out pair, outside of
the `vlib/v/tests/known_errors/testdata/` folder.
## Test building of actual V programs (examples, tools, V itself)
@@ -133,21 +152,23 @@ Run `vlib` module tests, *including* the compiler tests.
## `v vlib/v/compiler_errors_test.v`
This runs tests for:
* `vlib/v/scanner/tests/*.vv`
* `vlib/v/checker/tests/*.vv`
* `vlib/v/parser/tests/*.vv`
NB: there are special folders, that compiler_errors_test.v will try to
run/compile with specific options:
> **Note**
> There are special folders, that compiler_errors_test.v will try to
> run/compile with specific options:
vlib/v/checker/tests/globals_run/ - `-enable-globals run`;
vlib/v/checker/tests/globals_run/ - `-enable-globals run`;
results stored in `.run.out` files, matching the .vv ones.
NB 2: in case you need to modify many .out files, run *twice* in a row:
`VAUTOFIX=1 ./v vlib/v/compiler_errors_test.v`
`VAUTOFIX=1 ./v vlib/v/compiler_errors_test.v`
This will fail the first time, but it will record the new output for each
.vv file, and store it into the corresponding .out file. The second run
should be now successfull, and so you can inspect the difference, and
should be now successful, and so you can inspect the difference, and
commit the new .out files with minimum manual effort.
NB 3: To run only some of the tests, use:

View File

@@ -10,17 +10,17 @@ fn main() {
sample_size := 10000000
min_str_len := 20
max_str_len := 40
println('Generating $sample_size strings between $min_str_len - $max_str_len chars long...')
println('Generating ${sample_size} strings between ${min_str_len} - ${max_str_len} chars long...')
mut checksum := u64(0)
mut start_pos := 0
mut bgenerating := benchmark.start()
mut bytepile := []byte{}
mut bytepile := []u8{}
for _ in 0 .. sample_size * max_str_len {
bytepile << byte(rand.int_in_range(40, 125))
bytepile << u8(rand.int_in_range(40, 125) or { 40 })
}
mut str_lens := []int{}
for _ in 0 .. sample_size {
str_lens << rand.int_in_range(min_str_len, max_str_len)
str_lens << rand.int_in_range(min_str_len, max_str_len) or { min_str_len }
}
bgenerating.measure('generating strings')
println('Hashing each of the generated strings...')
@@ -30,7 +30,7 @@ fn main() {
checksum = 0
for len in str_lens {
end_pos := start_pos + len
checksum ^= wyhash.wyhash_c(unsafe { &byte(bytepile.data) + start_pos }, u64(len),
checksum ^= wyhash.wyhash_c(unsafe { &u8(bytepile.data) + start_pos }, u64(len),
1)
start_pos = end_pos
}

View File

@@ -0,0 +1,7 @@
module main
import v.builder.golangbuilder
fn main() {
golangbuilder.start()
}

View File

@@ -0,0 +1,7 @@
module main
import v.builder.wasmbuilder
fn main() {
wasmbuilder.start()
}

View File

@@ -40,10 +40,10 @@ mut:
}
fn main() {
vexe := pref.vexe_path()
vexe := os.real_path(os.getenv_opt('VEXE') or { @VEXE })
vroot := os.dir(vexe)
util.set_vroot_folder(vroot)
os.chdir(vroot) ?
os.chdir(vroot)!
cmd := diff.find_working_diff_command() or { '' }
mut app := App{
diff_cmd: cmd
@@ -52,7 +52,7 @@ fn main() {
}
for mname in app.modules {
if !app.is_verbose {
eprintln('Checking module: $mname ...')
eprintln('Checking module: ${mname} ...')
}
api_base := app.gen_api_for_module_in_os(mname, base_os)
for oname in os_names {
@@ -65,9 +65,9 @@ fn main() {
}
howmany := app.api_differences.len
if howmany > 0 {
eprintln(term.header('Found $howmany modules with different APIs', '='))
eprintln(term.header('Found ${howmany} modules with different APIs', '='))
for m in app.api_differences.keys() {
eprintln('Module: $m')
eprintln('Module: ${m}')
}
exit(1)
}
@@ -108,7 +108,7 @@ fn (app App) gen_api_for_module_in_os(mod_name string, os_name string) string {
fn_signature := s.stringify(b.table, mod_name, map[string]string{})
fn_mod := s.modname()
if fn_mod == mod_name {
fline := '$fn_mod: $fn_signature'
fline := '${fn_mod}: ${fn_signature}'
res << fline
}
}
@@ -122,7 +122,7 @@ fn (app App) gen_api_for_module_in_os(mod_name string, os_name string) string {
fn (mut app App) compare_api(api_base string, api_os string, mod_name string, os_base string, os_target string) {
res := diff.color_compare_strings(app.diff_cmd, rand.ulid(), api_base, api_os)
if res.len > 0 {
summary := 'Different APIs found for module: `$mod_name`, between OS base: `$os_base` and OS: `$os_target`'
summary := 'Different APIs found for module: `${mod_name}`, between OS base: `${os_base}` and OS: `${os_target}`'
eprintln(term.header(summary, '-'))
eprintln(res)
eprintln(term.h_divider('-'))

View File

@@ -4,12 +4,14 @@ fn main() {
exit(0)
}
println('
NB: `tcc` was not used, so unless you install it yourself, your backend
$if !macos {
println('
Note: `tcc` was not used, so unless you install it yourself, your backend
C compiler will be `cc`, which is usually either `clang`, `gcc` or `msvc`.
These C compilers, are several times slower at compiling C source code,
compared to `tcc`. They do produce more optimised executables, but that
is done at the cost of compilation speed.
')
}
}

View File

@@ -3,3 +3,4 @@ index.html
table.html
v.c
v2
fast.log

View File

@@ -1,168 +1,220 @@
// Copyright (c) 2019-2022 Alexander Medvednikov. All rights reserved.
// Copyright (c) 2019-2023 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
import os
import time
import arrays
const warmup_samples = 2
const max_samples = 10
const discard_highest_samples = 6
// TODO -usecache
const voptions = ' -skip-unused -show-timings -stats '
const exe = os.executable()
const fast_dir = os.dir(@FILE)
const fast_dir = os.dir(exe)
const fast_log_path = os.join_path(fast_dir, 'fast.log')
const vdir = @VEXEROOT
const vdir = os.dir(os.dir(os.dir(fast_dir)))
fn elog(msg string) {
line := '${time.now().format_ss_micro()} ${msg}\n'
if mut f := os.open_append(fast_log_path) {
f.write_string(line) or {}
f.close()
}
eprint(line)
}
fn lsystem(cmd string) int {
elog('lsystem: ${cmd}')
return os.system(cmd)
}
fn lexec(cmd string) string {
elog(' lexec: ${cmd}')
return os.execute_or_exit(cmd).output.trim_right('\r\n')
}
fn main() {
dump(fast_dir)
dump(vdir)
os.chdir(fast_dir) ?
if !os.exists('$vdir/v') && !os.is_dir('$vdir/vlib') {
println('fast.html generator needs to be located in `v/cmd/tools/fast`')
total_sw := time.new_stopwatch()
elog('fast.html generator start')
defer {
elog('fast.html generator end, total: ${total_sw.elapsed().milliseconds():6} ms')
}
println('fast.html generator\n')
if !os.args.contains('-noupdate') {
println('Fetching updates...')
ret := os.system('$vdir/v up')
if ret != 0 {
println('failed to update V')
return
}
}
// Fetch the last commit's hash
commit := exec('git rev-parse HEAD')[..8]
if !os.exists('table.html') {
os.create('table.html') ?
}
mut table := os.read_file('table.html') ?
if os.exists('website/index.html') {
uploaded_index := os.read_file('website/index.html') ?
if uploaded_index.contains('>$commit<') {
println('nothing to benchmark')
exit(1)
return
}
}
// for i, commit in commits {
message := exec('git log --pretty=format:"%s" -n1 $commit')
// println('\n${i + 1}/$commits.len Benchmarking commit $commit "$message"')
println('\nBenchmarking commit $commit "$message"')
// Build an optimized V
// println('Checking out ${commit}...')
// exec('git checkout $commit')
println(' Building vprod...')
os.chdir(vdir) ?
if os.args.contains('-noprod') {
exec('./v -o vprod cmd/v') // for faster debugging
} else {
exec('./v -o vprod -prod -prealloc cmd/v')
}
// cache vlib modules
exec('$vdir/v wipe-cache')
exec('$vdir/v -o v2 -prod cmd/v')
// measure
diff1 := measure('$vdir/vprod $voptions -o v.c cmd/v', 'v.c')
mut tcc_path := 'tcc'
$if freebsd {
tcc_path = '/usr/local/bin/tcc'
if vdir.contains('/tmp/cirrus-ci-build') {
tcc_path = 'clang'
}
//
mut ccompiler_path := 'tcc'
if vdir.contains('/tmp/cirrus-ci-build') {
ccompiler_path = 'clang'
}
if os.args.contains('-clang') {
tcc_path = 'clang'
ccompiler_path = 'clang'
}
diff2 := measure('$vdir/vprod $voptions -cc $tcc_path -o v2 cmd/v', 'v2')
elog('fast_dir: ${fast_dir} | vdir: ${vdir} | compiler: ${ccompiler_path}')
os.chdir(fast_dir)!
if !os.exists('${vdir}/v') && !os.is_dir('${vdir}/vlib') {
elog('fast.html generator needs to be located in `v/cmd/tools/fast`')
exit(1)
}
if !os.exists('table.html') {
os.create('table.html')!
}
if !os.args.contains('-noupdate') {
elog('Fetching updates...')
ret := lsystem('${vdir}/v up')
if ret != 0 {
elog('failed to update V, exit_code: ${ret}')
return
}
}
// fetch the last commit's hash
commit := lexec('git rev-parse HEAD')[..8]
if os.exists('website/index.html') {
uploaded_index := os.read_file('website/index.html')!
if uploaded_index.contains('>${commit}<') {
elog('NOTE: commit ${commit} had been benchmarked already.')
if !os.args.contains('-force') {
elog('nothing more to do')
return
}
}
}
os.chdir(vdir)!
message := lexec('git log --pretty=format:"%s" -n1 ${commit}')
commit_date := lexec('git log -n1 --pretty="format:%at" ${commit}')
date := time.unix(commit_date.i64())
elog('Benchmarking commit ${commit} , with commit message: "${message}", commit_date: ${commit_date}, date: ${date}')
// build an optimized V
if os.args.contains('-do-not-rebuild-vprod') {
if !os.exists('vprod') {
elog('Exiting, since if you use `-do-not-rebuild-vprod`, you should already have a `${vdir}/vprod` executable, but it is missing!')
return
}
} else {
elog(' Building vprod...')
if os.args.contains('-noprod') {
lexec('./v -o vprod cmd/v') // for faster debugging
} else {
lexec('./v -o vprod -prod -prealloc cmd/v')
}
}
if !os.args.contains('-do-not-rebuild-caches') {
elog('clearing caches...')
// cache vlib modules
lexec('${vdir}/v wipe-cache')
lexec('${vdir}/v -o vwarm_caches -cc ${ccompiler_path} cmd/v')
}
// measure
diff1 := measure('${vdir}/vprod ${voptions} -o v.c cmd/v', 'v.c')
diff2 := measure('${vdir}/vprod ${voptions} -cc ${ccompiler_path} -o v2 cmd/v', 'v2')
diff3 := 0 // measure('$vdir/vprod -native $vdir/cmd/tools/1mil.v', 'native 1mil')
diff4 := measure('$vdir/vprod -usecache $voptions -cc clang examples/hello_world.v',
diff4 := measure('${vdir}/vprod ${voptions} -cc ${ccompiler_path} examples/hello_world.v',
'hello.v')
vc_size := os.file_size('v.c') / 1000
// scan/parse/check/cgen
scan, parse, check, cgen, vlines := measure_steps(vdir)
// println('Building V took ${diff}ms')
commit_date := exec('git log -n1 --pretty="format:%at" $commit')
date := time.unix(commit_date.int())
//
os.chdir(fast_dir) ?
mut out := os.create('table.html') ?
// Place the new row on top
scan, parse, check, cgen, vlines := measure_steps_minimal(vdir)!
html_message := message.replace_each(['<', '&lt;', '>', '&gt;'])
table =
'<tr>
<td>$date.format()</td>
<td><a target=_blank href="https://github.com/vlang/v/commit/$commit">$commit</a></td>
<td>$html_message</td>
os.chdir(fast_dir)!
// place the new row on top
table := os.read_file('table.html')!
new_table :=
' <tr>
<td>${date.format()}</td>
<td><a target=_blank href="https://github.com/vlang/v/commit/${commit}">${commit}</a></td>
<td>${html_message}</td>
<td>${diff1}ms</td>
<td>${diff2}ms</td>
<td>${diff3}ms</td>
<td>${diff4}ms</td>
<td>$vc_size KB</td>
<td>${vc_size} KB</td>
<td>${parse}ms</td>
<td>${check}ms</td>
<td>${cgen}ms</td>
<td>${scan}ms</td>
<td>$vlines</td>
<td>${vlines}</td>
<td>${int(f64(vlines) / f64(diff1) * 1000.0)}</td>
</tr>\n' +
table.trim_space()
out.writeln(table) ?
out.close()
// Regenerate index.html
header := os.read_file('header.html') ?
footer := os.read_file('footer.html') ?
mut res := os.create('index.html') ?
res.writeln(header) ?
res.writeln(table) ?
res.writeln(footer) ?
table.trim_space() + '\n'
os.write_file('table.html', new_table)!
// regenerate index.html
header := os.read_file('header.html')!
footer := os.read_file('footer.html')!
mut res := os.create('index.html')!
res.writeln(header)!
res.writeln(new_table)!
res.writeln(footer)!
res.close()
//}
// exec('git checkout master')
// os.write_file('last_commit.txt', commits[commits.len - 1]) ?
// Upload the result to github pages
// upload the result to github pages
if os.args.contains('-upload') {
println('uploading...')
os.chdir('website') ?
os.execute_or_exit('git checkout gh-pages')
os.cp('../index.html', 'index.html') ?
os.rm('../index.html') ?
os.system('git commit -am "update benchmark"')
os.system('git push origin gh-pages')
elog('uploading...')
os.chdir('website')!
lexec('git checkout gh-pages')
os.mv('../index.html', 'index.html')!
lsystem('git commit -am "update benchmark"')
lsystem('git push origin gh-pages')
elog('uploading done')
}
}
fn exec(s string) string {
e := os.execute_or_exit(s)
return e.output.trim_right('\r\n')
}
// returns milliseconds
// measure returns milliseconds
fn measure(cmd string, description string) int {
println(' Measuring $description')
println(' Warming up...')
println(cmd)
for _ in 0 .. 3 {
exec(cmd)
elog(' Measuring ${description}, warmups: ${warmup_samples}, samples: ${max_samples}, discard: ${discard_highest_samples}, with cmd: `${cmd}`')
for _ in 0 .. warmup_samples {
os.execute_or_exit(cmd)
}
println(' Building...')
mut runs := []int{}
for r in 0 .. 5 {
println(' Sample ${r + 1}/5')
for r in 0 .. max_samples {
sw := time.new_stopwatch()
exec(cmd)
runs << int(sw.elapsed().milliseconds())
os.execute_or_exit(cmd)
sample := int(sw.elapsed().milliseconds())
runs << sample
elog(' Sample ${r + 1:2}/${max_samples:2} ... ${sample} ms')
}
// discard lowest and highest time
runs.sort()
runs = runs[1..4]
mut sum := 0
for run in runs {
sum += run
elog(' runs before discarding: ${runs}, avg: ${f64(arrays.sum(runs) or { 0 }) / runs.len:5.2f}')
// Discard the highest times, since on AWS, they are caused by random load spikes,
// that are unpredictable, add noise and skew the statistics, without adding useful
// insights:
for _ in 0 .. discard_highest_samples {
runs.pop()
}
return int(sum / 3)
elog(' runs after discarding: ${runs}, avg: ${f64(arrays.sum(runs) or { 0 }) / runs.len:5.2f}')
return int(f64(arrays.sum(runs) or { 0 }) / runs.len)
}
fn measure_steps(vdir string) (int, int, int, int, int) {
resp := os.execute_or_exit('$vdir/vprod $voptions -o v.c cmd/v')
fn measure_steps_minimal(vdir string) !(int, int, int, int, int) {
elog('measure_steps_minimal ${vdir}, samples: ${max_samples}')
mut scans, mut parses, mut checks, mut cgens, mut vliness := []int{}, []int{}, []int{}, []int{}, []int{}
for i in 0 .. max_samples {
scan, parse, check, cgen, vlines, cmd := measure_steps_one_sample(vdir)
scans << scan
parses << parse
checks << check
cgens << cgen
vliness << vlines
elog(' [${i:2}/${max_samples:2}] scan: ${scan} ms, min parse: ${parse} ms, min check: ${check} ms, min cgen: ${cgen} ms, min vlines: ${vlines} ms, cmd: ${cmd}')
}
scan, parse, check, cgen, vlines := arrays.min(scans)!, arrays.min(parses)!, arrays.min(checks)!, arrays.min(cgens)!, arrays.min(vliness)!
elog('measure_steps_minimal => min scan: ${scan} ms, min parse: ${parse} ms, min check: ${check} ms, min cgen: ${cgen} ms, min vlines: ${vlines} ms')
return scan, parse, check, cgen, vlines
}
fn measure_steps_one_sample(vdir string) (int, int, int, int, int, string) {
cmd := '${vdir}/vprod ${voptions} -o v.c cmd/v'
resp := os.execute_or_exit(cmd)
mut scan, mut parse, mut check, mut cgen, mut vlines := 0, 0, 0, 0, 0
lines := resp.output.split_into_lines()
@@ -187,7 +239,7 @@ fn measure_steps(vdir string) (int, int, int, int, int) {
cgen = line[0].int()
}
} else {
// Fetch number of V lines
// fetch number of V lines
if line[0].contains('V') && line[0].contains('source') && line[0].contains('size') {
start := line[0].index(':') or { 0 }
end := line[0].index('lines,') or { 0 }
@@ -197,5 +249,5 @@ fn measure_steps(vdir string) (int, int, int, int, int) {
}
}
}
return scan, parse, check, cgen, vlines
return scan, parse, check, cgen, vlines, cmd
}

View File

@@ -1,37 +1,80 @@
// Copyright (c) 2019-2022 Alexander Medvednikov. All rights reserved.
// Copyright (c) 2019-2023 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
import os
import time
const fast_dir = os.dir(@FILE)
const vdir = os.dir(os.dir(os.dir(fast_dir)))
const vexe = os.join_path(vdir, 'v')
const sleep_period = 120
fn elog(msg string) {
eprintln('${time.now().format_ss_micro()} ${msg}')
}
fn delay() {
elog('Sleeping for ${sleep_period} seconds...')
time.sleep(sleep_period * time.second)
}
// A job that runs in the background, checks for repo updates,
// runs fast.v, pushes the HTML result to the fast.vlang.io GH pages repo.
fn main() {
println(time.now())
os.setenv('LANG', 'C', true)
elog('fast_job fast_dir: ${fast_dir} | vdir: ${vdir} | vexe: ${vexe}')
os.chdir(fast_dir)!
elog('fast_job start in os.getwd(): ${os.getwd()}')
defer {
elog('fast_job end')
}
if !os.exists('website') {
println('cloning the website repo...')
os.system('git clone git@github.com:/vlang/website.git')
}
if !os.exists('fast') {
println('"fast" binary (built with `v fast.v`) was not found')
return
}
for {
elog('------------------- Checking for updates ... -------------------')
res_pull := os.execute('git pull --rebase')
elog('> res_pull.output: ${res_pull.output}')
if res_pull.exit_code != 0 {
println('failed to git pull. uncommitted changes?')
return
elog('Git pull failed. You may have uncommitted changes?')
delay()
continue
}
// println('running ./fast')
resp := os.execute('./fast -upload')
if resp.exit_code < 0 {
println(resp.output)
return
if res_pull.output.contains('Already up to date.') {
if os.args.contains('-force-update') {
elog('The repository was already updated, but -force-update was passed too.')
} else {
delay()
continue
}
}
if resp.exit_code != 0 {
println('resp != 0, skipping')
println(resp.output)
elog('recompiling V')
os.system('${os.quoted_path(vexe)} self')
os.system('ls -la ${os.quoted_path(vexe)}')
elog('recompiling ./fast')
recompile_fast_v_code := os.system('${os.quoted_path(vexe)} fast.v')
if recompile_fast_v_code != 0 {
elog('WARNING: could not recompile fast.v')
delay()
continue
}
time.sleep(180 * time.second)
os.system('ls -la fast fast.v')
elog('running ./fast -upload')
fast_exit_code := os.system('./fast -upload')
if fast_exit_code != 0 {
println('fast_exit_code = ${fast_exit_code}, != 0')
}
delay()
}
}

View File

@@ -8,23 +8,34 @@
*, body {
font-family: Menlo, Monospace, 'Courier New';
}
table {
width: 1800px;
}
table, td {
table, td, th {
border-collapse: collapse;
border: 1px solid #dfdfdf;
}
th {
background-color: lightgray;
color: black;
padding: 5px;
}
td {
padding: 5px;
position: relative;
}
table td:nth-child(3) {
width: 650px!important;
overflow: hidden;
display: block;
border: 0px;
border-bottom: 1px solid lightgray;
}
.diff {
border-radius: 2.5px;
color: #ffffff;
padding: 0 5px 0 5px;
position: absolute;
right: 5px;
font-size: 14px;
bottom: 0px;
right: 0px;
}
.minus {
background-color: rgb(195, 74, 104);
@@ -38,28 +49,27 @@ td {
</style>
</head>
<body>
<h2>Is V still fast?</h2>
<h2><a href='/'>Is V still fast?</a></h2>
Monitoring compilation speed for each commit. <br><br>
Running on a free tier AWS t2.micro instance (1 vCPU). Typical desktop hardware is 2-3 times faster. <br><br>
Source code: <a target=blank href='https://github.com/vlang/v/blob/master/cmd/tools/fast/fast.v'>fast.v</a> <br><br>
Older stats: <a href="2023.html">2023</a>, <a href="2022.html">2022</a>, <a href="2021.html">2021</a>, <a href="2020.html">2020</a><br><br>
<table>
<tr>
<td style='width:180px'>timestamp</td>
<td style='width:85px'>commit</td>
<td>commit message</td>
<td style='width:120px'>v -o v.c</td>
<td style='width:120px'>v -o v</td>
<td style='width:130px'>v -native 1mil.v</td>
<td style='width:120px'>v hello.v</td>
<td style='width:85px'>v.c size</td>
<td style='width:55px'>parse</td>
<td style='width:55px'>check</td>
<td style='width:55px'>cgen</td>
<td style='width:55px'>scan</td>
<td style='width:80px'>V lines</td>
<td style='width:95px'>V lines/s</td>
<th style='width:180px'>&nbsp;&nbsp;&nbsp;&nbsp;Timestamp&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th style='width:85px'>Commit</th>
<th class='cmessage'>Commit Message</td>
<th style='width:120px;white-space: nowrap'>v -o v.c</th>
<th style='width:120px;white-space: nowrap'>v -o v</th>
<th style='width:130px'>v -native 1mil.v</th>
<th style='width:120px;white-space: nowrap'>v hello.v</th>
<th style='width:85px;white-space: nowrap'>v.c size</th>
<th style='width:55px;white-space: nowrap'>parse</th>
<th style='width:55px'>check</th>
<th style='width:55px'>cgen</th>
<th style='width:55px'>scan</th>
<th style='width:80px;white-space: nowrap'>V lines</th>
<th style='width:95px;white-space: nowrap'>V lines/s</th>
</tr>

View File

@@ -10,9 +10,9 @@ fn generate_strings(str_len int, arr_len int) []string {
}
fn fuzz1() {
amount := 200000 - rand.intn(100000)
amount2 := 200000 - rand.intn(100000)
len := 25 - rand.intn(10)
amount := 200000 - rand.intn(100000) or { 0 }
amount2 := 200000 - rand.intn(100000) or { 0 }
len := 25 - rand.intn(10) or { 0 }
arr := generate_strings(len, amount)
arr2 := generate_strings(len, amount2)
mut m := map[string]int{}
@@ -34,8 +34,8 @@ fn fuzz1() {
fn fuzz2() {
mut m := map[string]int{}
amount := rand.intn(500000) + 1
len := 25 - rand.intn(10)
amount := rand.intn(500000) or { 0 } + 1
len := 25 - rand.intn(10) or { 0 }
arr := generate_strings(len, amount)
for i, x in arr {
m[x] = i
@@ -54,8 +54,8 @@ fn fuzz2() {
fn fuzz3() {
mut m := map[string]int{}
amount := rand.intn(500000) + 1
len := 25 - rand.intn(10)
amount := rand.intn(500000) or { 0 } + 1
len := 25 - rand.intn(10) or { 0 }
arr := generate_strings(len, amount)
for i, x in arr {
if (i % 10000) == 0 {
@@ -74,8 +74,8 @@ fn fuzz3() {
}
fn fuzz4() {
amount := rand.intn(500000)
len := 25 - rand.intn(10)
amount := rand.intn(500000) or { 0 }
len := 25 - rand.intn(10) or { 0 }
arr := generate_strings(len, amount)
mut m := map[string]int{}
for i in 0 .. amount {
@@ -93,7 +93,7 @@ fn fuzz4() {
}
fn fuzz5() {
amount := rand.intn(500000) + 1
amount := rand.intn(500000) or { 0 } + 1
arr := generate_strings(20, amount)
mut m := map[string]int{}
for i in 0 .. amount {
@@ -114,8 +114,8 @@ fn fuzz5() {
fn fuzz6() {
mut m := map[string]int{}
amount := rand.intn(500000) + 1
len := 25 - rand.intn(10)
amount := rand.intn(500000) or { 0 } + 1
len := 25 - rand.intn(10) or { 0 }
arr := generate_strings(len, amount)
for i, x in arr {
m[x]++
@@ -133,7 +133,7 @@ fn fuzz6() {
fn main() {
seed := u32(time.ticks())
println('seed: $seed.hex()')
println('seed: ${seed.hex()}')
rand.seed([seed, seed])
fuzz1()
fuzz2()

View File

@@ -2,7 +2,7 @@ fn main() {
for i in 0 .. 100000 {
println('
fn foo${i}() {
x := $i
x := ${i}
mut a := 1 + x
a += 2
print(a)

View File

@@ -64,7 +64,7 @@ const (
// server port
server_port = 7171
// log file
log_file = '$work_dir/log.txt'
log_file = '${work_dir}/log.txt'
// log_to is either 'file' or 'terminal'
log_to = 'terminal'
)
@@ -82,7 +82,7 @@ struct GenVC {
// flag options
options FlagOptions
mut:
logger &log.Log
logger &log.Log = unsafe { nil }
// true if error was experienced running generate
gen_error bool
}
@@ -91,7 +91,7 @@ mut:
struct WebhookServer {
vweb.Context
mut:
gen_vc &GenVC = 0 // initialized in init_server
gen_vc &GenVC = unsafe { nil } // initialized in init_server
}
// storage for flag options
@@ -125,7 +125,7 @@ fn main() {
}
// webhook server mode
if flag_options.serve {
vweb.run<WebhookServer>(&WebhookServer{}, flag_options.port)
vweb.run[WebhookServer](&WebhookServer{}, flag_options.port)
} else {
// cmd mode
mut gen_vc := new_gen_vc(flag_options)
@@ -209,7 +209,7 @@ fn (mut gen_vc GenVC) generate() {
os.mkdir(gen_vc.options.work_dir) or { panic(err) }
// still dosen't exist... we have a problem
if !os.is_dir(gen_vc.options.work_dir) {
gen_vc.logger.error('error creating directory: $gen_vc.options.work_dir')
gen_vc.logger.error('error creating directory: ${gen_vc.options.work_dir}')
gen_vc.gen_error = true
return
}
@@ -221,10 +221,10 @@ fn (mut gen_vc GenVC) generate() {
// first check to see if the local v repo is behind master
// if it isn't behind theres no point continuing further
if !gen_vc.options.serve && os.is_dir(git_repo_dir_v) {
gen_vc.cmd_exec('git -C $git_repo_dir_v checkout master')
gen_vc.cmd_exec('git -C ${git_repo_dir_v} checkout master')
// fetch the remote repo just in case there are newer commits there
gen_vc.cmd_exec('git -C $git_repo_dir_v fetch')
git_status := gen_vc.cmd_exec('git -C $git_repo_dir_v status')
gen_vc.cmd_exec('git -C ${git_repo_dir_v} fetch')
git_status := gen_vc.cmd_exec('git -C ${git_repo_dir_v} status')
if !git_status.contains('behind') && !gen_vc.options.force {
gen_vc.logger.warn('v repository is already up to date.')
return
@@ -233,11 +233,11 @@ fn (mut gen_vc GenVC) generate() {
// delete repos
gen_vc.purge_repos()
// clone repos
gen_vc.cmd_exec('git clone --depth 1 https://$git_repo_v $git_repo_dir_v')
gen_vc.cmd_exec('git clone --depth 1 https://$git_repo_vc $git_repo_dir_vc')
gen_vc.cmd_exec('git clone --depth 1 https://${git_repo_v} ${git_repo_dir_v}')
gen_vc.cmd_exec('git clone --depth 1 https://${git_repo_vc} ${git_repo_dir_vc}')
// get output of git log -1 (last commit)
git_log_v := gen_vc.cmd_exec('git -C $git_repo_dir_v log -1 --format="commit %H%nDate: %ci%nDate Unix: %ct%nSubject: %s"')
git_log_vc := gen_vc.cmd_exec('git -C $git_repo_dir_vc log -1 --format="Commit %H%nDate: %ci%nDate Unix: %ct%nSubject: %s"')
git_log_v := gen_vc.cmd_exec('git -C ${git_repo_dir_v} log -1 --format="commit %H%nDate: %ci%nDate Unix: %ct%nSubject: %s"')
git_log_vc := gen_vc.cmd_exec('git -C ${git_repo_dir_vc} log -1 --format="Commit %H%nDate: %ci%nDate Unix: %ct%nSubject: %s"')
// date of last commit in each repo
ts_v := git_log_v.find_between('Date:', '\n').trim_space()
ts_vc := git_log_vc.find_between('Date:', '\n').trim_space()
@@ -255,45 +255,45 @@ fn (mut gen_vc GenVC) generate() {
last_commit_subject := git_log_v.find_between('Subject:', '\n').trim_space().replace("'",
'"')
// log some info
gen_vc.logger.debug('last commit time ($git_repo_v): ' + last_commit_time_v.format_ss())
gen_vc.logger.debug('last commit time ($git_repo_vc): ' + last_commit_time_vc.format_ss())
gen_vc.logger.debug('last commit hash ($git_repo_v): $last_commit_hash_v')
gen_vc.logger.debug('last commit subject ($git_repo_v): $last_commit_subject')
gen_vc.logger.debug('last commit time (${git_repo_v}): ' + last_commit_time_v.format_ss())
gen_vc.logger.debug('last commit time (${git_repo_vc}): ' + last_commit_time_vc.format_ss())
gen_vc.logger.debug('last commit hash (${git_repo_v}): ${last_commit_hash_v}')
gen_vc.logger.debug('last commit subject (${git_repo_v}): ${last_commit_subject}')
// if vc repo already has a newer commit than the v repo, assume it's up to date
if t_unix_vc >= t_unix_v && !gen_vc.options.force {
gen_vc.logger.warn('vc repository is already up to date.')
return
}
// try build v for current os (linux in this case)
gen_vc.cmd_exec('make -C $git_repo_dir_v')
v_exec := '$git_repo_dir_v/v'
gen_vc.cmd_exec('make -C ${git_repo_dir_v}')
v_exec := '${git_repo_dir_v}/v'
// check if make was successful
gen_vc.assert_file_exists_and_is_not_too_short(v_exec, err_msg_make)
// build v.c for each os
for os_name in vc_build_oses {
c_file := if os_name == 'nix' { 'v.c' } else { 'v_win.c' }
v_flags := if os_name == 'nix' { '-os cross' } else { '-os $os_name' }
v_flags := if os_name == 'nix' { '-os cross' } else { '-os ${os_name}' }
// try generate .c file
gen_vc.cmd_exec('$v_exec $v_flags -o $c_file $git_repo_dir_v/cmd/v')
gen_vc.cmd_exec('${v_exec} ${v_flags} -o ${c_file} ${git_repo_dir_v}/cmd/v')
// check if the c file seems ok
gen_vc.assert_file_exists_and_is_not_too_short(c_file, err_msg_gen_c)
// embed the latest v commit hash into the c file
gen_vc.cmd_exec('sed -i \'1s/^/#define V_COMMIT_HASH "$last_commit_hash_v_short"\\n/\' $c_file')
gen_vc.cmd_exec('sed -i \'1s/^/#define V_COMMIT_HASH "${last_commit_hash_v_short}"\\n/\' ${c_file}')
// move to vc repo
gen_vc.cmd_exec('mv $c_file $git_repo_dir_vc/$c_file')
gen_vc.cmd_exec('mv ${c_file} ${git_repo_dir_vc}/${c_file}')
// add new .c file to local vc repo
gen_vc.cmd_exec('git -C $git_repo_dir_vc add $c_file')
gen_vc.cmd_exec('git -C ${git_repo_dir_vc} add ${c_file}')
}
// check if the vc repo actually changed
git_status := gen_vc.cmd_exec('git -C $git_repo_dir_vc status')
git_status := gen_vc.cmd_exec('git -C ${git_repo_dir_vc} status')
if git_status.contains('nothing to commit') {
gen_vc.logger.error('no changes to vc repo: something went wrong.')
gen_vc.gen_error = true
}
// commit changes to local vc repo
gen_vc.cmd_exec_safe("git -C $git_repo_dir_vc commit -m '[v:master] $last_commit_hash_v_short - $last_commit_subject'")
gen_vc.cmd_exec_safe("git -C ${git_repo_dir_vc} commit -m '[v:master] ${last_commit_hash_v_short} - ${last_commit_subject}'")
// push changes to remote vc repo
gen_vc.cmd_exec_safe('git -C $git_repo_dir_vc push https://${urllib.query_escape(git_username)}:${urllib.query_escape(git_password)}@$git_repo_vc master')
gen_vc.cmd_exec_safe('git -C ${git_repo_dir_vc} push https://${urllib.query_escape(git_username)}:${urllib.query_escape(git_password)}@${git_repo_vc} master')
}
// only execute when dry_run option is false, otherwise just log
@@ -312,10 +312,10 @@ fn (mut gen_vc GenVC) command_execute(cmd string, dry bool) string {
if dry {
return gen_vc.command_execute_dry(cmd)
}
gen_vc.logger.info('cmd: $cmd')
gen_vc.logger.info('cmd: ${cmd}')
r := os.execute(cmd)
if r.exit_code < 0 {
gen_vc.logger.error('$err_msg_cmd_x: "$cmd" could not start.')
gen_vc.logger.error('${err_msg_cmd_x}: "${cmd}" could not start.')
gen_vc.logger.error(r.output)
// something went wrong, better start fresh next time
gen_vc.purge_repos()
@@ -323,7 +323,7 @@ fn (mut gen_vc GenVC) command_execute(cmd string, dry bool) string {
return ''
}
if r.exit_code != 0 {
gen_vc.logger.error('$err_msg_cmd_x: "$cmd" failed.')
gen_vc.logger.error('${err_msg_cmd_x}: "${cmd}" failed.')
gen_vc.logger.error(r.output)
// something went wrong, better start fresh next time
gen_vc.purge_repos()
@@ -335,35 +335,35 @@ fn (mut gen_vc GenVC) command_execute(cmd string, dry bool) string {
// just log cmd, dont execute
fn (mut gen_vc GenVC) command_execute_dry(cmd string) string {
gen_vc.logger.info('cmd (dry): "$cmd"')
gen_vc.logger.info('cmd (dry): "${cmd}"')
return ''
}
// delete repo directories
fn (mut gen_vc GenVC) purge_repos() {
// delete old repos (better to be fully explicit here, since these are destructive operations)
mut repo_dir := '$gen_vc.options.work_dir/$git_repo_dir_v'
mut repo_dir := '${gen_vc.options.work_dir}/${git_repo_dir_v}'
if os.is_dir(repo_dir) {
gen_vc.logger.info('purging local repo: "$repo_dir"')
gen_vc.cmd_exec('rm -rf $repo_dir')
gen_vc.logger.info('purging local repo: "${repo_dir}"')
gen_vc.cmd_exec('rm -rf ${repo_dir}')
}
repo_dir = '$gen_vc.options.work_dir/$git_repo_dir_vc'
repo_dir = '${gen_vc.options.work_dir}/${git_repo_dir_vc}'
if os.is_dir(repo_dir) {
gen_vc.logger.info('purging local repo: "$repo_dir"')
gen_vc.cmd_exec('rm -rf $repo_dir')
gen_vc.logger.info('purging local repo: "${repo_dir}"')
gen_vc.cmd_exec('rm -rf ${repo_dir}')
}
}
// check if file size is too short
fn (mut gen_vc GenVC) assert_file_exists_and_is_not_too_short(f string, emsg string) {
if !os.exists(f) {
gen_vc.logger.error('$err_msg_build: $emsg .')
gen_vc.logger.error('${err_msg_build}: ${emsg} .')
gen_vc.gen_error = true
return
}
fsize := os.file_size(f)
if fsize < too_short_file_limit {
gen_vc.logger.error('$err_msg_build: $f exists, but is too short: only $fsize bytes.')
gen_vc.logger.error('${err_msg_build}: ${f} exists, but is too short: only ${fsize} bytes.')
gen_vc.gen_error = true
return
}

View File

@@ -0,0 +1,52 @@
#!/usr/bin/env -S v -raw-vsh-tmp-prefix tmp
import os
import term
// This script can be used to ensure that all commited V files are vfmt-ed automatically.
// By default, once setup, it will run `v fmt -w` on them, before commiting them.
// To use the script in your V project, you need to be in the main folder
// of your project, then do the equivalent of:
// ```sh
// cp /PATH/TO_YOUR/V/cmd/tools/git_pre_commit_hook.vsh .git/hooks/pre-commit
// chmod 755 .git/hooks/pre-commit
// ```
//
// Note: you can use this command:
// `git config --bool --add hooks.stopCommitOfNonVfmtedVFiles true`
// ... to make it just *prevent* the commiting of unformatted .v files,
// i.e. stop the commiting, if they are not, but *without modifying them*
// automatically (you will then need to run `v fmt -w` on them manually).
//
// Note 2: Git supports skipping the hooks, by passing the `--no-verify` option.
// That can be used to commit some .v files that are not formatted, without removing
// the hook.
fn main() {
// This hook cares only about the changed V files, that will be commited, as reported by git itself:
changed := os.execute('git diff --cached --name-only --diff-filter=ACMR -- "*.v" "*.vsh" "*.vv"')
if changed.output == '' {
eprintln('>>> 0 changed V files found.')
exit(0)
}
vfiles := changed.output.trim_space().split('\n')
configured_stop_commiting := os.execute('git config --bool hooks.stopCommitOfNonVfmtedVFiles')
if configured_stop_commiting.output.trim_space().bool() {
verify_result := os.execute('v fmt -verify ${vfiles.join(' ')}')
if verify_result.exit_code != 0 {
eprintln(verify_result.output)
}
exit(verify_result.exit_code)
} else {
eprintln('The V pre commit hook will format ${vfiles.len} V file(s):')
// vfmt off
for vfile in vfiles {
eprintln(' ${term.bold('$vfile')}')
}
// vfmt on
all_vfiles_on_a_line := vfiles.map(os.quoted_path(it)).join(' ')
os.system('v fmt -w ${all_vfiles_on_a_line}')
os.system('git add ${all_vfiles_on_a_line}')
}
}

74
cmd/tools/install_binaryen.vsh Executable file
View File

@@ -0,0 +1,74 @@
#!/usr/bin/env -S v -raw-vsh-tmp-prefix tmp
import os
import net.http
const github_job = os.getenv('GITHUB_JOB')
struct JQ {
tag_name string
}
fn main() {
root := os.real_path(os.dir(os.getenv_opt('VEXE') or { @VEXE }))
os.chdir(root)! // make sure that the workfolder is stable
tloc := os.join_path(root, 'thirdparty')
loc := os.join_path(tloc, 'binaryen')
if os.exists(loc) {
eprintln('thirdparty/binaryen exists, will not overwrite')
eprintln('delete the folder, and execute again')
exit(1)
}
/*
// TODO: add retries here, github requests can fail
jq := http.get_text('https://api.github.com/repos/WebAssembly/binaryen/releases/latest')
tag := json.decode(JQ, jq)!.tag_name
if github_job != '' {
dump(jq)
dump(tag)
}
*/
tag := 'version_112'
name := $if windows {
'x86_64-windows'
} $else $if macos {
$if arm64 {
'arm64-macos'
} $else {
'x86_64-macos'
}
} $else $if linux {
'x86_64-linux'
} $else {
eprintln('A premade binary library is not available for your system.')
eprintln('Build it from source, following the documentation here: https://github.com/WebAssembly/binaryen/#building')
exit(1)
}
fname := 'binaryen-${tag}'
url := 'https://github.com/WebAssembly/binaryen/releases/download/${tag}/${fname}-${name}.tar.gz'
saveloc := os.join_path(tloc, '${fname}.tar.gz')
if !os.exists(saveloc) {
println('Downloading archive: ${saveloc}, from url: ${url} ...')
http.download_file(url, saveloc)!
// defer { os.rm(saveloc) or {}! }
}
println('Extracting `${tloc}/${fname}` to `${tloc}/binaryen` ...')
cmd := 'tar -xvf ${saveloc} --directory ${tloc}'
if os.system(cmd) != 0 {
eprintln('`${cmd}` exited with a non zero exit code')
exit(1)
}
println(cmd)
println('Moving `${tloc}/${fname}` to `${tloc}/binaryen` ...')
os.rename_dir('${tloc}/${fname}', loc)!
println('Done. You can now use `v -b wasm file.v` .')
}

View File

@@ -0,0 +1,52 @@
#!/usr/bin/env -S v -raw-vsh-tmp-prefix tmp
import os
import net.http
const root = @VROOT
fn main() {
os.chdir(root)! // make sure that the workfolder is stable
tloc := os.join_path(root, 'thirdparty')
loc := os.join_path(tloc, 'wabt')
if os.exists(loc) {
eprintln('thirdparty/wabt exists, will not overwrite')
eprintln('delete the folder, and execute again')
exit(1)
}
tag := '1.0.32'
fname := 'wabt-${tag}'
platform := $if windows {
'windows'
} $else $if macos {
'macos-12'
} $else $if linux {
'ubuntu'
} $else {
eprintln('A premade binary library is not available for your system.')
eprintln('Build it from source, following the documentation here: https://github.com/WebAssembly/wabt/')
exit(1)
}
url := 'https://github.com/WebAssembly/wabt/releases/download/${tag}/${fname}-${platform}.tar.gz'
saveloc := os.join_path(tloc, '${fname}.tar.gz')
if !os.exists(saveloc) {
println('Downloading archive: ${saveloc}, from url: ${url} ...')
http.download_file(url, saveloc)!
// defer { os.rm(saveloc) or {}! }
}
println('Extracting `${tloc}/${fname}` to `${tloc}/wabt` ...')
cmd := 'tar -xvf ${saveloc} --directory ${tloc}'
if os.system(cmd) != 0 {
eprintln('`${cmd}` exited with a non zero exit code')
exit(1)
}
println(cmd)
println('Moving `${tloc}/${fname}` to `${tloc}/wabt` ...')
os.rename_dir('${tloc}/${fname}', loc)!
println('Done. You can now use `v test vlib/wasm` .')
}

View File

@@ -0,0 +1,67 @@
import os
import time
import v.ast
import v.pref
import v.parser
import v.errors
import v.scanner
fn main() {
files := os.args#[1..]
if files.len > 0 && files[0].starts_with('@') {
lst_path := files[0].all_after('@')
listed_files := os.read_file(lst_path)!.split('\n')
process_files(listed_files)!
return
}
process_files(files)!
}
fn process_files(files []string) ! {
mut table := ast.new_table()
mut pref_ := pref.new_preferences()
pref_.is_fmt = true
pref_.skip_warnings = true
pref_.output_mode = .silent
mut sw := time.new_stopwatch()
mut total_us := i64(0)
mut total_bytes := i64(0)
mut total_tokens := i64(0)
for f in files {
if f == '' {
continue
}
if f.ends_with('_test.v') {
continue
}
// do not measure the scanning, but only the parsing:
mut p := new_parser(f, .skip_comments, table, pref_)
///
sw.restart()
_ := p.parse()
f_us := sw.elapsed().microseconds()
///
total_us += f_us
total_bytes += p.scanner.text.len
total_tokens += p.scanner.all_tokens.len
println('${f_us:10}us ${p.scanner.all_tokens.len:10} ${p.scanner.text.len:10} ${(f64(p.scanner.text.len) / p.scanner.all_tokens.len):7.3} ${p.errors.len:4} ${f}')
}
println('${total_us:10}us ${total_tokens:10} ${total_bytes:10} ${(f64(total_tokens) / total_bytes):7.3} | speed: ${(f64(total_bytes) / total_us):2.5f} MB/s')
}
fn new_parser(path string, comments_mode scanner.CommentsMode, table &ast.Table, pref_ &pref.Preferences) &parser.Parser {
mut p := &parser.Parser{
scanner: scanner.new_scanner_file(path, comments_mode, pref_) or { panic(err) }
comments_mode: comments_mode
table: table
pref: pref_
scope: &ast.Scope{
start_pos: 0
parent: table.global_scope
}
errors: []errors.Error{}
warnings: []errors.Warning{}
}
p.set_path(path)
return p
}

View File

@@ -0,0 +1,42 @@
import os
import time
import v.scanner
import v.pref
fn main() {
files := os.args#[1..]
if files.len > 0 && files[0].starts_with('@') {
lst_path := files[0].all_after('@')
listed_files := os.read_file(lst_path)!.split('\n')
process_files(listed_files)!
return
}
process_files(files)!
}
fn process_files(files []string) ! {
mut pref_ := pref.new_preferences()
pref_.is_fmt = true
pref_.skip_warnings = true
pref_.output_mode = .silent
mut sw := time.new_stopwatch()
mut total_us := i64(0)
mut total_bytes := i64(0)
mut total_tokens := i64(0)
for f in files {
if f == '' {
continue
}
if f.ends_with('_test.v') {
continue
}
sw.restart()
s := scanner.new_scanner_file(f, .skip_comments, pref_)!
f_us := sw.elapsed().microseconds()
total_us += f_us
total_bytes += s.text.len
total_tokens += s.all_tokens.len
println('${f_us:10}us ${s.all_tokens.len:10} ${s.text.len:10} ${(f64(s.text.len) / s.all_tokens.len):7.3f} ${f}')
}
println('${total_us:10}us ${total_tokens:10} ${total_bytes:10} ${(f64(total_tokens) / total_bytes):7.3f} | speed: ${(f64(total_bytes) / total_us):2.5f} MB/s')
}

View File

@@ -1,141 +0,0 @@
// Copyright (c) 2020 Lars Pontoppidan. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
import os
import flag
const (
tool_name = os.file_name(os.executable())
tool_version = '0.0.2'
tool_description = 'Prints all V functions in .v files under PATH/, that do not yet have documentation comments.'
)
struct UndocumentedFN {
line int
signature string
tags []string
}
struct Options {
show_help bool
collect_tags bool
deprecated bool
}
fn collect(path string, mut l []string, f fn (string, mut []string)) {
if !os.is_dir(path) {
return
}
mut files := os.ls(path) or { return }
for file in files {
p := path + os.path_separator + file
if os.is_dir(p) && !os.is_link(p) {
collect(p, mut l, f)
} else if os.exists(p) {
f(p, mut l)
}
}
return
}
fn report_undocumented_functions_in_path(opt Options, path string) {
mut files := []string{}
collect_fn := fn (path string, mut l []string) {
if os.file_ext(path) == '.v' {
l << os.real_path(path)
}
}
collect(path, mut files, collect_fn)
for file in files {
if file.ends_with('_test.v') {
continue
}
report_undocumented_functions_in_file(opt, file)
}
}
fn report_undocumented_functions_in_file(opt Options, file string) {
contents := os.read_file(file) or { panic(err) }
lines := contents.split('\n')
mut info := []UndocumentedFN{}
for i, line in lines {
if line.starts_with('pub fn') || (line.starts_with('fn ') && !(line.starts_with('fn C.')
|| line.starts_with('fn main'))) {
// println('Match: $line')
if i > 0 && lines.len > 0 {
mut line_above := lines[i - 1]
if !line_above.starts_with('//') {
mut tags := []string{}
mut grab := true
for j := i - 1; j >= 0; j-- {
prev_line := lines[j]
if prev_line.contains('}') { // We've looked back to the above scope, stop here
break
} else if prev_line.starts_with('[') {
tags << collect_tags(prev_line)
continue
} else if prev_line.starts_with('//') { // Single-line comment
grab = false
break
}
}
if grab {
clean_line := line.all_before_last(' {')
info << UndocumentedFN{i + 1, clean_line, tags}
}
}
}
}
}
if info.len > 0 {
for undocumented_fn in info {
tags_str := if opt.collect_tags && undocumented_fn.tags.len > 0 {
'$undocumented_fn.tags'
} else {
''
}
if opt.deprecated {
println('$file:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
} else {
if 'deprecated' !in undocumented_fn.tags {
println('$file:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
}
}
}
}
}
fn collect_tags(line string) []string {
mut cleaned := line.all_before('/')
cleaned = cleaned.replace_each(['[', '', ']', '', ' ', ''])
return cleaned.split(',')
}
fn main() {
if os.args.len == 1 {
println('Usage: $tool_name PATH \n$tool_description\n$tool_name -h for more help...')
exit(1)
}
mut fp := flag.new_flag_parser(os.args[1..])
fp.application(tool_name)
fp.version(tool_version)
fp.description(tool_description)
fp.arguments_description('PATH [PATH]...')
// Collect tool options
opt := Options{
show_help: fp.bool('help', `h`, false, 'Show this help text.')
deprecated: fp.bool('deprecated', `d`, false, 'Include deprecated functions in output.')
collect_tags: fp.bool('tags', `t`, false, 'Also print function tags if any is found.')
}
if opt.show_help {
println(fp.usage())
exit(0)
}
for path in os.args[1..] {
if os.is_file(path) {
report_undocumented_functions_in_file(opt, path)
} else {
report_undocumented_functions_in_path(opt, path)
}
}
}

View File

@@ -24,6 +24,7 @@ pub fn cprint(omessage string) {
message = term.cyan(message)
}
print(message)
flush_stdout()
}
pub fn cprint_strong(omessage string) {
@@ -32,33 +33,36 @@ pub fn cprint_strong(omessage string) {
message = term.bright_green(message)
}
print(message)
flush_stdout()
}
pub fn cprintln(omessage string) {
cprint(omessage)
println('')
flush_stdout()
}
pub fn cprintln_strong(omessage string) {
cprint_strong(omessage)
println('')
flush_stdout()
}
pub fn verbose_trace(label string, message string) {
if os.getenv('VERBOSE').len > 0 {
slabel := '$time.now().format_ss_milli() $label'
cprintln('# ${slabel:-43s} : $message')
slabel := '${time.now().format_ss_milli()} ${label}'
cprintln('# ${slabel:-43s} : ${message}')
}
}
pub fn verbose_trace_strong(label string, omessage string) {
if os.getenv('VERBOSE').len > 0 {
slabel := '$time.now().format_ss_milli() $label'
slabel := '${time.now().format_ss_milli()} ${label}'
mut message := omessage
if scripting.term_colors {
message = term.bright_green(message)
}
cprintln('# ${slabel:-43s} : $message')
cprintln('# ${slabel:-43s} : ${message}')
}
}
@@ -72,7 +76,7 @@ pub fn verbose_trace_exec_result(x os.Result) {
if scripting.term_colors {
line = term.bright_green(line)
}
cprintln('# ${lnum:3d}: $line')
cprintln('# ${lnum:3d}: ${line}')
lnum++
}
cprintln('# ----------------------------------------------------------------------')
@@ -80,27 +84,27 @@ pub fn verbose_trace_exec_result(x os.Result) {
}
fn modfn(mname string, fname string) string {
return '${mname}.$fname'
return '${mname}.${fname}'
}
pub fn chdir(path string) {
verbose_trace_strong(modfn(@MOD, @FN), 'cd $path')
verbose_trace_strong(modfn(@MOD, @FN), 'cd ${path}')
os.chdir(path) or {
verbose_trace(modfn(@MOD, @FN), '## failed.')
return
}
}
pub fn mkdir(path string) ? {
verbose_trace_strong(modfn(@MOD, @FN), 'mkdir $path')
pub fn mkdir(path string) ! {
verbose_trace_strong(modfn(@MOD, @FN), 'mkdir ${path}')
os.mkdir(path) or {
verbose_trace(modfn(@MOD, @FN), '## failed.')
return err
}
}
pub fn mkdir_all(path string) ? {
verbose_trace_strong(modfn(@MOD, @FN), 'mkdir -p $path')
pub fn mkdir_all(path string) ! {
verbose_trace_strong(modfn(@MOD, @FN), 'mkdir -p ${path}')
os.mkdir_all(path) or {
verbose_trace(modfn(@MOD, @FN), '## failed.')
return err
@@ -108,7 +112,7 @@ pub fn mkdir_all(path string) ? {
}
pub fn rmrf(path string) {
verbose_trace_strong(modfn(@MOD, @FN), 'rm -rf $path')
verbose_trace_strong(modfn(@MOD, @FN), 'rm -rf ${path}')
if os.exists(path) {
if os.is_dir(path) {
os.rmdir_all(path) or { panic(err) }
@@ -119,7 +123,7 @@ pub fn rmrf(path string) {
}
// execute a command, and return a result, or an error, if it failed in any way.
pub fn exec(cmd string) ?os.Result {
pub fn exec(cmd string) !os.Result {
verbose_trace_strong(modfn(@MOD, @FN), cmd)
x := os.execute(cmd)
if x.exit_code != 0 {
@@ -161,10 +165,10 @@ pub fn exit_0_status(cmd string) bool {
pub fn tool_must_exist(toolcmd string) {
verbose_trace(modfn(@MOD, @FN), toolcmd)
if exit_0_status('type $toolcmd') {
if exit_0_status('type ${toolcmd}') {
return
}
eprintln('Missing tool: $toolcmd')
eprintln('Missing tool: ${toolcmd}')
eprintln('Please try again after you install it.')
exit(1)
}
@@ -178,6 +182,6 @@ pub fn used_tools_must_exist(tools []string) {
pub fn show_sizes_of_files(files []string) {
for f in files {
size := os.file_size(f)
println('$size $f') // println('${size:10d} $f')
println('${size} ${f}') // println('${size:10d} $f')
}
}

View File

@@ -1,9 +1,11 @@
module testing
import os
import os.cmdline
import time
import term
import benchmark
import sync
import sync.pool
import v.pref
import v.util.vtest
@@ -19,13 +21,24 @@ pub const hide_oks = os.getenv('VTEST_HIDE_OK') == '1'
pub const fail_fast = os.getenv('VTEST_FAIL_FAST') == '1'
pub const fail_flaky = os.getenv('VTEST_FAIL_FLAKY') == '1'
pub const test_only = os.getenv('VTEST_ONLY').split_any(',')
pub const test_only_fn = os.getenv('VTEST_ONLY_FN').split_any(',')
pub const is_node_present = os.execute('node --version').exit_code == 0
pub const all_processes = os.execute('ps ax').output.split_any('\r\n')
pub const all_processes = get_all_processes()
fn get_all_processes() []string {
$if windows {
// TODO
return []
} $else {
return os.execute('ps ax').output.split_any('\r\n')
}
}
pub struct TestSession {
pub mut:
@@ -35,30 +48,17 @@ pub mut:
vroot string
vtmp_dir string
vargs string
failed bool
fail_fast bool
benchmark benchmark.Benchmark
rm_binaries bool = true
silent_mode bool
show_stats bool
progress_mode bool
root_relative bool // used by CI runs, so that the output is stable everywhere
nmessages chan LogMessage // many publishers, single consumer/printer
nmessage_idx int // currently printed message index
nprint_ended chan int // read to block till printing ends, 1:1
nmessage_idx int // currently printed message index
failed_cmds shared []string
}
enum MessageKind {
ok
fail
skip
info
sentinel
}
struct LogMessage {
message string
kind MessageKind
reporter Reporter = Reporter(NormalReporter{})
}
pub fn (mut ts TestSession) add_failed_cmd(cmd string) {
@@ -68,44 +68,84 @@ pub fn (mut ts TestSession) add_failed_cmd(cmd string) {
}
pub fn (mut ts TestSession) show_list_of_failed_tests() {
for i, cmd in ts.failed_cmds {
eprintln(term.failed('Failed command ${i + 1}:') + ' $cmd')
rlock ts.failed_cmds {
ts.reporter.list_of_failed_commands(ts.failed_cmds)
}
}
pub fn (mut ts TestSession) append_message(kind MessageKind, msg string) {
struct MessageThreadContext {
mut:
file string
flow_id string
}
fn (mut ts TestSession) append_message(kind MessageKind, msg string, mtc MessageThreadContext) {
ts.nmessages <- LogMessage{
file: mtc.file
flow_id: mtc.flow_id
message: msg
kind: kind
when: time.now()
}
}
fn (mut ts TestSession) append_message_with_duration(kind MessageKind, msg string, d time.Duration, mtc MessageThreadContext) {
ts.nmessages <- LogMessage{
file: mtc.file
flow_id: mtc.flow_id
message: msg
kind: kind
when: time.now()
took: d
}
}
pub fn (mut ts TestSession) session_start(message string) {
ts.reporter.session_start(message, mut ts)
}
pub fn (mut ts TestSession) session_stop(message string) {
ts.reporter.session_stop(message, mut ts)
}
pub fn (mut ts TestSession) print_messages() {
empty := term.header(' ', ' ')
mut test_idx := 0
mut print_msg_time := time.new_stopwatch()
for {
// get a message from the channel of messages to be printed:
mut rmessage := <-ts.nmessages
ts.nmessage_idx++
// first sent *all events* to the output reporter, so it can then process them however it wants:
ts.reporter.report(ts.nmessage_idx, rmessage)
if rmessage.kind in [.cmd_begin, .cmd_end] {
// The following events, are sent before the test framework has determined,
// what the full completion status is. They can also be repeated multiple times,
// for tests that are flaky and need repeating.
continue
}
if rmessage.kind == .sentinel {
// a sentinel for stopping the printing thread
if !ts.silent_mode && ts.progress_mode {
eprintln('')
ts.reporter.report_stop()
}
ts.nprint_ended <- 0
return
}
if rmessage.kind != .info {
ts.nmessage_idx++
// info events can also be repeated, and should be ignored when determining
// the total order of the current test file, in the following replacements:
test_idx++
}
msg := rmessage.message.replace_each([
'TMP1',
'${ts.nmessage_idx:1d}',
'${test_idx:1d}',
'TMP2',
'${ts.nmessage_idx:2d}',
'${test_idx:2d}',
'TMP3',
'${ts.nmessage_idx:3d}',
'${test_idx:3d}',
'TMP4',
'${ts.nmessage_idx:4d}',
'${test_idx:4d}',
])
is_ok := rmessage.kind == .ok
//
@@ -114,24 +154,21 @@ pub fn (mut ts TestSession) print_messages() {
// Even if OK tests are suppressed,
// show *at least* 1 result every 10 seconds,
// otherwise the CI can seem stuck ...
eprintln(msg)
ts.reporter.progress(ts.nmessage_idx, msg)
print_msg_time.restart()
continue
}
if ts.progress_mode {
// progress mode, the last line is rewritten many times:
if is_ok && !ts.silent_mode {
print('\r$empty\r$msg')
ts.reporter.update_last_line(ts.nmessage_idx, msg)
} else {
// the last \n is needed, so SKIP/FAIL messages
// will not get overwritten by the OK ones
eprint('\r$empty\r$msg\n')
ts.reporter.update_last_line_and_move_to_next(ts.nmessage_idx, msg)
}
continue
}
if !ts.silent_mode || !is_ok {
// normal expanded mode, or failures in -silent mode
eprintln(msg)
ts.reporter.message(ts.nmessage_idx, msg)
continue
}
}
@@ -140,6 +177,14 @@ pub fn (mut ts TestSession) print_messages() {
pub fn new_test_session(_vargs string, will_compile bool) TestSession {
mut skip_files := []string{}
if will_compile {
// Skip the call_v_from_c files. They need special instructions for compilation.
// Check the README.md for detailed information.
skip_files << 'examples/call_v_from_c/v_test_print.v'
skip_files << 'examples/call_v_from_c/v_test_math.v'
// Skip the compilation of the coroutines example for now, since the Photon wrapper
// is only available on macos for now, and it is not yet trivial enough to
// build/install on the CI:
skip_files << 'examples/coroutines/simple_coroutines.v'
$if msvc {
skip_files << 'vlib/v/tests/const_comptime_eval_before_vinit_test.v' // _constructor used
}
@@ -157,13 +202,34 @@ pub fn new_test_session(_vargs string, will_compile bool) TestSession {
$if windows {
skip_files << 'examples/database/mysql.v'
skip_files << 'examples/database/orm.v'
skip_files << 'examples/smtp/mail.v' // requires OpenSSL
skip_files << 'examples/websocket/ping.v' // requires OpenSSL
skip_files << 'examples/websocket/client-server/client.v' // requires OpenSSL
skip_files << 'examples/websocket/client-server/server.v' // requires OpenSSL
skip_files << 'vlib/v/tests/websocket_logger_interface_should_compile_test.v' // requires OpenSSL
$if tinyc {
skip_files << 'examples/database/orm.v' // try fix it
}
}
$if windows {
// TODO: remove when closures on windows are supported...
skip_files << 'examples/pendulum-simulation/animation.v'
skip_files << 'examples/pendulum-simulation/full.v'
skip_files << 'examples/pendulum-simulation/parallel.v'
skip_files << 'examples/pendulum-simulation/parallel_with_iw.v'
skip_files << 'examples/pendulum-simulation/sequential.v'
}
if testing.github_job == 'ubuntu-docker-musl' {
skip_files << 'vlib/net/openssl/openssl_compiles_test.v'
}
if testing.github_job == 'tests-sanitize-memory-clang' {
skip_files << 'vlib/net/openssl/openssl_compiles_test.v'
}
if testing.github_job == 'windows-tcc' {
// TODO: fix these by adding declarations for the missing functions in the prebuilt tcc
skip_files << 'vlib/net/mbedtls/mbedtls_compiles_test.v'
skip_files << 'vlib/net/ssl/ssl_compiles_test.v'
}
if testing.github_job != 'sokol-shaders-can-be-compiled' {
// These examples need .h files that are produced from the supplied .glsl files,
// using by the shader compiler tools in https://github.com/floooh/sokol-tools-bin/archive/pre-feb2021-api-changes.tar.gz
@@ -187,24 +253,68 @@ pub fn new_test_session(_vargs string, will_compile bool) TestSession {
skip_files << 'examples/sokol/sounds/wav_player.v'
skip_files << 'examples/sokol/sounds/simple_sin_tones.v'
}
$if !macos {
skip_files << 'examples/macos_tray/tray.v'
}
// examples/wasm/mandelbrot/mandelbrot.v requires special compilation flags: `-b wasm -os browser`, skip it for now:
skip_files << 'examples/wasm/mandelbrot/mandelbrot.v'
// TODO: always build the wasm_builder in the future, not just when it was build manually before:
wasm_builder_executable := $if !windows {
'cmd/tools/builders/wasm_builder'
} $else {
'cmd/tools/builders/wasm_builder.exe'
}
if !os.exists(wasm_builder_executable) {
skip_files << os.join_path('cmd/tools/builders/wasm_builder.v')
}
}
vargs := _vargs.replace('-progress', '').replace('-progress', '')
vargs := _vargs.replace('-progress', '')
vexe := pref.vexe_path()
vroot := os.dir(vexe)
new_vtmp_dir := setup_new_vtmp_folder()
if term.can_show_color_on_stderr() {
os.setenv('VCOLORS', 'always', true)
}
return TestSession{
mut ts := TestSession{
vexe: vexe
vroot: vroot
skip_files: skip_files
fail_fast: testing.fail_fast
show_stats: '-stats' in vargs.split(' ')
vargs: vargs
vtmp_dir: new_vtmp_dir
silent_mode: _vargs.contains('-silent')
progress_mode: _vargs.contains('-progress')
}
ts.handle_test_runner_option()
return ts
}
fn (mut ts TestSession) handle_test_runner_option() {
test_runner := cmdline.option(os.args, '-test-runner', 'normal')
if test_runner !in pref.supported_test_runners {
eprintln('v test: `-test-runner ${test_runner}` is not using one of the supported test runners: ${pref.supported_test_runners_list()}')
}
test_runner_implementation_file := os.join_path(ts.vroot, 'cmd/tools/modules/testing/output_${test_runner}.v')
if !os.exists(test_runner_implementation_file) {
eprintln('v test: using `-test-runner ${test_runner}` needs ${test_runner_implementation_file} to exist, and contain a valid testing.Reporter implementation for that runner. See `cmd/tools/modules/testing/output_dump.v` for an example.')
exit(1)
}
match test_runner {
'normal' {
// default, nothing to do
}
'dump' {
ts.reporter = DumpReporter{}
}
'teamcity' {
ts.reporter = TeamcityReporter{}
}
else {
dump('just set ts.reporter to an instance of your own struct here')
}
}
}
pub fn (mut ts TestSession) init() {
@@ -254,37 +364,43 @@ pub fn (mut ts TestSession) test() {
}
ts.benchmark.njobs = njobs
mut pool_of_test_runners := pool.new_pool_processor(callback: worker_trunner)
// for handling messages across threads
// ensure that the nmessages queue/channel, has enough capacity for handling many messages across threads, without blocking
ts.nmessages = chan LogMessage{cap: 10000}
ts.nprint_ended = chan int{cap: 0}
ts.nmessage_idx = 0
go ts.print_messages()
printing_thread := spawn ts.print_messages()
pool_of_test_runners.set_shared_context(ts)
ts.reporter.worker_threads_start(remaining_files, mut ts)
// all the testing happens here:
pool_of_test_runners.work_on_pointers(unsafe { remaining_files.pointers() })
//
ts.benchmark.stop()
ts.append_message(.sentinel, '') // send the sentinel
_ := <-ts.nprint_ended // wait for the stop of the printing thread
eprintln(term.h_divider('-'))
ts.append_message(.sentinel, '', MessageThreadContext{ flow_id: '-1' }) // send the sentinel
printing_thread.wait()
ts.reporter.worker_threads_finish(mut ts)
ts.reporter.divider()
ts.show_list_of_failed_tests()
// cleanup generated .tmp.c files after successful tests:
if ts.benchmark.nfail == 0 {
if ts.rm_binaries {
os.rmdir_all(ts.vtmp_dir) or {}
}
}
ts.show_list_of_failed_tests()
// remove empty session folders:
if os.ls(ts.vtmp_dir) or { [] }.len == 0 {
os.rmdir_all(ts.vtmp_dir) or {}
}
}
fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
mut ts := &TestSession(p.get_shared_context())
mut ts := unsafe { &TestSession(p.get_shared_context()) }
if ts.fail_fast {
if ts.failed {
if ts.failed_cmds.len > 0 {
return pool.no_result
}
}
tmpd := ts.vtmp_dir
show_stats := '-stats' in ts.vargs.split(' ')
// tls_bench is used to format the step messages/timings
mut tls_bench := &benchmark.Benchmark(p.get_thread_context(idx))
mut tls_bench := unsafe { &benchmark.Benchmark(p.get_thread_context(idx)) }
if isnil(tls_bench) {
tls_bench = benchmark.new_benchmark_pointer()
tls_bench.set_total_expected_steps(ts.benchmark.nexpected_steps)
@@ -292,17 +408,19 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
}
tls_bench.no_cstep = true
tls_bench.njobs = ts.benchmark.njobs
mut relative_file := os.real_path(p.get_item<string>(idx))
mut relative_file := os.real_path(p.get_item[string](idx))
mut cmd_options := [ts.vargs]
mut run_js := false
is_fmt := ts.vargs.contains('fmt')
is_vet := ts.vargs.contains('vet')
produces_file_output := !(is_fmt || is_vet)
if relative_file.ends_with('js.v') {
if !is_fmt {
if produces_file_output {
cmd_options << ' -b js'
run_js = true
}
run_js = true
}
if relative_file.contains('global') && !is_fmt {
@@ -312,6 +430,10 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
relative_file = relative_file.replace(ts.vroot + os.path_separator, '')
}
file := os.real_path(relative_file)
mtc := MessageThreadContext{
file: file
flow_id: thread_id.str()
}
normalised_relative_file := relative_file.replace('\\', '/')
// Ensure that the generated binaries will be stored in the temporary folder.
// Remove them after a test passes/fails.
@@ -324,13 +446,11 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
fname.replace('.v', '')
}
generated_binary_fpath := os.join_path_single(tmpd, generated_binary_fname)
if os.exists(generated_binary_fpath) {
if produces_file_output {
if ts.rm_binaries {
os.rm(generated_binary_fpath) or {}
}
}
if !ts.vargs.contains('fmt') {
cmd_options << ' -o ${os.quoted_path(generated_binary_fpath)}'
}
cmd := '${os.quoted_path(ts.vexe)} ' + cmd_options.join(' ') + ' ${os.quoted_path(file)}'
@@ -340,20 +460,42 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
ts.benchmark.skip()
tls_bench.skip()
if !testing.hide_skips {
ts.append_message(.skip, tls_bench.step_message_skip(normalised_relative_file))
ts.append_message(.skip, tls_bench.step_message_skip(normalised_relative_file),
mtc)
}
return pool.no_result
}
if show_stats {
ts.append_message(.ok, term.h_divider('-'))
mut status := os.system(cmd)
if ts.show_stats {
ts.reporter.divider()
ts.append_message(.cmd_begin, cmd, mtc)
d_cmd := time.new_stopwatch()
mut res := os.execute(cmd)
if res.exit_code != 0 {
eprintln(res.output)
} else {
println(res.output)
}
mut status := res.exit_code
mut cmd_duration := d_cmd.elapsed()
ts.append_message_with_duration(.cmd_end, '', cmd_duration, mtc)
if status != 0 {
details := get_test_details(file)
os.setenv('VTEST_RETRY_MAX', '$details.retry', true)
os.setenv('VTEST_RETRY_MAX', '${details.retry}', true)
for retry := 1; retry <= details.retry; retry++ {
ts.append_message(.info, ' retrying $retry/$details.retry of $relative_file ...')
os.setenv('VTEST_RETRY', '$retry', true)
ts.append_message(.info, ' [stats] retrying ${retry}/${details.retry} of ${relative_file} ; known flaky: ${details.flaky} ...',
mtc)
os.setenv('VTEST_RETRY', '${retry}', true)
ts.append_message(.cmd_begin, cmd, mtc)
d_cmd_2 := time.new_stopwatch()
status = os.system(cmd)
cmd_duration = d_cmd_2.elapsed()
ts.append_message_with_duration(.cmd_end, '', cmd_duration, mtc)
if status == 0 {
unsafe {
goto test_passed_system
@@ -361,7 +503,19 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
}
time.sleep(500 * time.millisecond)
}
ts.failed = true
if details.flaky && !testing.fail_flaky {
ts.append_message(.info, ' *FAILURE* of the known flaky test file ${relative_file} is ignored, since VTEST_FAIL_FLAKY is 0 . Retry count: ${details.retry} .',
mtc)
unsafe {
goto test_passed_system
}
}
// most probably compiler error
if res.output.contains(': error: ') {
ts.append_message(.cannot_compile, 'Cannot compile file ${file}', mtc)
}
ts.benchmark.fail()
tls_bench.fail()
ts.add_failed_cmd(cmd)
@@ -373,49 +527,68 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
}
} else {
if testing.show_start {
ts.append_message(.info, ' starting $relative_file ...')
ts.append_message(.info, ' starting ${relative_file} ...',
mtc)
}
ts.append_message(.cmd_begin, cmd, mtc)
d_cmd := time.new_stopwatch()
mut r := os.execute(cmd)
mut cmd_duration := d_cmd.elapsed()
ts.append_message_with_duration(.cmd_end, r.output, cmd_duration, mtc)
if r.exit_code < 0 {
ts.failed = true
ts.benchmark.fail()
tls_bench.fail()
ts.append_message(.fail, tls_bench.step_message_fail(normalised_relative_file))
ts.append_message_with_duration(.fail, tls_bench.step_message_fail(normalised_relative_file),
cmd_duration, mtc)
ts.add_failed_cmd(cmd)
return pool.no_result
}
if r.exit_code != 0 {
details := get_test_details(file)
os.setenv('VTEST_RETRY_MAX', '$details.retry', true)
os.setenv('VTEST_RETRY_MAX', '${details.retry}', true)
for retry := 1; retry <= details.retry; retry++ {
ts.append_message(.info, ' retrying $retry/$details.retry of $relative_file ...')
os.setenv('VTEST_RETRY', '$retry', true)
ts.append_message(.info, ' retrying ${retry}/${details.retry} of ${relative_file} ; known flaky: ${details.flaky} ...',
mtc)
os.setenv('VTEST_RETRY', '${retry}', true)
ts.append_message(.cmd_begin, cmd, mtc)
d_cmd_2 := time.new_stopwatch()
r = os.execute(cmd)
cmd_duration = d_cmd_2.elapsed()
ts.append_message_with_duration(.cmd_end, r.output, cmd_duration, mtc)
if r.exit_code == 0 {
unsafe {
goto test_passed_execute
}
}
}
ts.failed = true
if details.flaky && !testing.fail_flaky {
ts.append_message(.info, ' *FAILURE* of the known flaky test file ${relative_file} is ignored, since VTEST_FAIL_FLAKY is 0 . Retry count: ${details.retry} .',
mtc)
unsafe {
goto test_passed_execute
}
}
ts.benchmark.fail()
tls_bench.fail()
ending_newline := if r.output.ends_with('\n') { '\n' } else { '' }
ts.append_message(.fail, tls_bench.step_message_fail('$normalised_relative_file\n$r.output.trim_space()$ending_newline'))
ts.append_message_with_duration(.fail, tls_bench.step_message_fail('${normalised_relative_file}\n${r.output.trim_space()}${ending_newline}'),
cmd_duration, mtc)
ts.add_failed_cmd(cmd)
} else {
test_passed_execute:
ts.benchmark.ok()
tls_bench.ok()
if !testing.hide_oks {
ts.append_message(.ok, tls_bench.step_message_ok(normalised_relative_file))
ts.append_message_with_duration(.ok, tls_bench.step_message_ok(normalised_relative_file),
cmd_duration, mtc)
}
}
}
if os.exists(generated_binary_fpath) {
if ts.rm_binaries {
os.rm(generated_binary_fpath) or {}
}
if produces_file_output && ts.rm_binaries {
os.rm(generated_binary_fpath) or {}
}
return pool.no_result
}
@@ -423,7 +596,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
pub fn vlib_should_be_present(parent_dir string) {
vlib_dir := os.join_path_single(parent_dir, 'vlib')
if !os.is_dir(vlib_dir) {
eprintln('$vlib_dir is missing, it must be next to the V executable')
eprintln('${vlib_dir} is missing, it must be next to the V executable')
exit(1)
}
}
@@ -435,7 +608,7 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
vargs := zargs.replace(vexe, '')
eheader(main_label)
if vargs.len > 0 {
eprintln('v compiler args: "$vargs"')
eprintln('v compiler args: "${vargs}"')
}
mut session := new_test_session(vargs, true)
files := os.walk_ext(os.join_path_single(parent_dir, folder), '.v')
@@ -443,12 +616,12 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
mut skipped := oskipped.clone()
next_file: for f in files {
fnormalised := f.replace('\\', '/')
// NB: a `testdata` folder, is the preferred name of a folder, containing V code,
// Note: a `testdata` folder, is the preferred name of a folder, containing V code,
// that you *do not want* the test framework to find incidentally for various reasons,
// for example module import tests, or subtests, that are compiled/run by other parent tests
// in specific configurations, etc.
if fnormalised.contains('testdata/') || fnormalised.contains('modules/')
|| f.contains('preludes/') {
|| fnormalised.contains('preludes/') {
continue
}
$if windows {
@@ -466,7 +639,8 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
skipped << skipped_f
}
for skip_prefix in oskipped {
if f.starts_with(skip_prefix) {
skip_folder := skip_prefix + '/'
if fnormalised.starts_with(skip_folder) {
continue next_file
}
}
@@ -480,13 +654,13 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
pub type FnTestSetupCb = fn (mut session TestSession)
pub fn v_build_failing_skipped(zargs string, folder string, oskipped []string, cb FnTestSetupCb) bool {
main_label := 'Building $folder ...'
finish_label := 'building $folder'
main_label := 'Building ${folder} ...'
finish_label := 'building ${folder}'
mut session := prepare_test_session(zargs, folder, oskipped, main_label)
cb(mut session)
session.test()
eprintln(session.benchmark.total_message(finish_label))
return session.failed
return session.failed_cmds.len > 0
}
pub fn build_v_cmd_failed(cmd string) bool {
@@ -510,22 +684,22 @@ pub fn building_any_v_binaries_failed() bool {
vlib_should_be_present(parent_dir)
os.chdir(parent_dir) or { panic(err) }
mut failed := false
v_build_commands := ['$vexe -o v_g -g cmd/v', '$vexe -o v_prod_g -prod -g cmd/v',
'$vexe -o v_cg -cg cmd/v', '$vexe -o v_prod_cg -prod -cg cmd/v',
'$vexe -o v_prod -prod cmd/v']
v_build_commands := ['${vexe} -o v_g -g cmd/v',
'${vexe} -o v_prod_g -prod -g cmd/v', '${vexe} -o v_cg -cg cmd/v',
'${vexe} -o v_prod_cg -prod -cg cmd/v', '${vexe} -o v_prod -prod cmd/v']
mut bmark := benchmark.new_benchmark()
for cmd in v_build_commands {
bmark.step()
if build_v_cmd_failed(cmd) {
bmark.fail()
failed = true
eprintln(bmark.step_message_fail('command: $cmd . See details above ^^^^^^^'))
eprintln(bmark.step_message_fail('command: ${cmd} . See details above ^^^^^^^'))
eprintln('')
continue
}
bmark.ok()
if !testing.hide_oks {
eprintln(bmark.step_message_ok('command: $cmd'))
eprintln(bmark.step_message_ok('command: ${cmd}'))
}
}
bmark.stop()
@@ -534,17 +708,12 @@ pub fn building_any_v_binaries_failed() bool {
return failed
}
pub fn eheader(msg string) {
eprintln(term.header_left(msg, '-'))
}
pub fn header(msg string) {
println(term.header_left(msg, '-'))
}
// setup_new_vtmp_folder creates a new nested folder inside VTMP, then resets VTMP to it,
// so that V programs/tests will write their temporary files to new location.
// The new nested folder, and its contents, will get removed after all tests/programs succeed.
pub fn setup_new_vtmp_folder() string {
now := time.sys_mono_now()
new_vtmp_dir := os.join_path(os.temp_dir(), 'v', 'test_session_$now')
new_vtmp_dir := os.join_path(os.vtmp_dir(), 'tsession_${sync.thread_id().hex()}_${now}')
os.mkdir_all(new_vtmp_dir) or { panic(err) }
os.setenv('VTMP', new_vtmp_dir, true)
return new_vtmp_dir
@@ -553,6 +722,7 @@ pub fn setup_new_vtmp_folder() string {
pub struct TestDetails {
pub mut:
retry int
flaky bool // when flaky tests fail, the whole run is still considered successfull, unless VTEST_FAIL_FLAKY is 1
}
pub fn get_test_details(file string) TestDetails {
@@ -562,15 +732,27 @@ pub fn get_test_details(file string) TestDetails {
if line.starts_with('// vtest retry:') {
res.retry = line.all_after(':').trim_space().int()
}
if line.starts_with('// vtest flaky:') {
res.flaky = line.all_after(':').trim_space().bool()
}
}
return res
}
pub fn find_started_process(pname string) ?string {
pub fn find_started_process(pname string) !string {
for line in testing.all_processes {
if line.contains(pname) {
return line
}
}
return error('could not find process matching $pname')
return error('could not find process matching ${pname}')
}
pub fn eheader(msg string) {
eprintln(term.header_left(msg, '-'))
}
pub fn header(msg string) {
println(term.header_left(msg, '-'))
flush_stdout()
}

View File

@@ -0,0 +1,46 @@
module testing
import time
pub enum MessageKind {
cmd_begin // sent right before *each* _test.v file execution, the resulting status is not known yet, but the _test.v file itself is
cmd_end // sent right after *each* _test.v file execution, the message contains the output of that execution
//
ok // success of a _test.v file
fail // failed _test.v file, one or more assertions failed
skip // the _test.v file was skipped for some reason
info // a generic information message, detailing the actions of the `v test` program (some tests could be repeated for example, and the details are sent with an .info status)
//
cannot_compile // when the _test.v file compiled with errors
//
sentinel // send just once after all executions are done; it signals that the reporting/printing thread should stop the loop and exit
}
pub struct LogMessage {
pub:
kind MessageKind // see the MessageKind declaration above
file string // the _test.v file that the message is about
when time.Time // when was the message sent (messages are sent by the execution threads at the *end* of each event)
flow_id string // the messages of each thread, producing LogMessage, will have all the same unique flowid. Messages by other threads will have other flowid. If you use VJOBS=1 to serialise the execution, then all messages will have the same flowid.
took time.Duration // the duration of the event, that this message describes
message string // the actual message text; the result of the event, that the message describes; most reporters could ignore this, since it could be reconstructed by the other fields
}
pub interface Reporter {
mut:
session_start(message string, mut ts TestSession) // called once per test session, in the main thread, suitable for setting up supporting infrastructure.
session_stop(message string, mut ts TestSession) // called once per test session, in the main thread, after everything else, suitable for summaries, creating .xml reports, uploads etc.
worker_threads_start(files []string, mut ts TestSession) // called once per test session, in the main thread, right before all the worker threads start
worker_threads_finish(mut ts TestSession) // called once per test session, in the main thread, right after all the worker threads finish
//
report(index int, log_msg LogMessage) // called once per each message, that will be shown (ok/fail/skip etc), only in the reporting thread.
report_stop() // called just once after all messages are processed, only in the reporting thread, but before stop_session.
//
// TODO: reconsider, whether the next methods, should be kept for all reporters, or just moved inside the normal reporter, to simplify the interface
progress(index int, message string)
update_last_line(index int, message string)
update_last_line_and_move_to_next(index int, message string)
message(index int, message string)
divider() // called to show a long ---------- horizontal line; can be safely ignored in most reporters; used in the main thread.
list_of_failed_commands(cmds []string) // called after all testing is done, to produce a small summary that only lists the failed commands, so that they can be retried manually if needed, without forcing the user to scroll and find them.
}

View File

@@ -0,0 +1,64 @@
module testing
// DumpReporter implements the interface testing.Reporter.
// It is used by `v -test-runner dump test .`
pub struct DumpReporter {
mut:
files []string
}
//
pub fn (mut r DumpReporter) worker_threads_start(files []string, mut ts TestSession) {
eprintln('> ${@METHOD} | files: ${files}')
r.files = files
}
pub fn (r DumpReporter) worker_threads_finish(mut ts TestSession) {
eprintln('> ${@METHOD}')
}
//
pub fn (r DumpReporter) session_start(message string, mut ts TestSession) {
eprintln('> ${@METHOD} | message: ${message}')
// dump(ts)
}
pub fn (r DumpReporter) session_stop(message string, mut ts TestSession) {
eprintln('> ${@METHOD} | message: ${message}')
}
//
pub fn (r DumpReporter) report(index int, message LogMessage) {
eprintln('> ${@METHOD} | index: ${index} | message: ${message}')
}
pub fn (r DumpReporter) report_stop() {
eprintln('> ${@METHOD}')
}
pub fn (r DumpReporter) progress(index int, message string) {
eprintln('> ${@METHOD} | index: ${index} | message: ${message}')
}
pub fn (r DumpReporter) update_last_line(index int, message string) {
eprintln('> ${@METHOD} | index: ${index} | message: ${message}')
}
pub fn (r DumpReporter) update_last_line_and_move_to_next(index int, message string) {
eprintln('> ${@METHOD} | index: ${index} | message: ${message}')
}
pub fn (r DumpReporter) message(index int, message string) {
eprintln('> ${@METHOD} | index: ${index} | message: ${message}')
}
pub fn (r DumpReporter) divider() {
eprintln('> ${@METHOD}')
}
pub fn (r DumpReporter) list_of_failed_commands(failed_cmds []string) {
eprintln('> ${@METHOD} | failed_cmds: ${failed_cmds}')
}

View File

@@ -0,0 +1,73 @@
module testing
import term
pub const empty = term.header(' ', ' ')
// NormalReporter implements the interface testing.Reporter.
// It is used by default by `v test .`
// It was extracted by the original non customiseable output implementation directly in cmd/tools/modules/testing/common.v
pub struct NormalReporter {
}
pub fn (r NormalReporter) session_start(message string, mut ts TestSession) {
header(message)
}
pub fn (r NormalReporter) session_stop(message string, mut ts TestSession) {
println(ts.benchmark.total_message(message))
}
// the most general form; it may be useful for other reporters
// in the normal one, it currently does nothing
pub fn (r NormalReporter) report(index int, message LogMessage) {
// eprintln('> ${@METHOD} index: $index | message: $message')
}
pub fn (r NormalReporter) report_stop() {
// eprintln('> ${@METHOD}')
eprintln('')
}
//// TODO: reconsider if these should be public:
pub fn (r NormalReporter) progress(index int, message string) {
eprintln(message)
}
// in progress mode, the last line will be rewritten many times, and does not end with \n
// the \n will be printed just once when some progress has been made.
pub fn (r NormalReporter) update_last_line(index int, message string) {
print('\r${testing.empty}\r${message}')
flush_stdout()
}
pub fn (r NormalReporter) update_last_line_and_move_to_next(index int, message string) {
// the last \n is needed, so SKIP/FAIL messages
// will not get overwritten by the OK ones
eprint('\r${testing.empty}\r${message}\n')
}
pub fn (r NormalReporter) message(index int, message string) {
eprintln(message)
}
pub fn (r NormalReporter) divider() {
eprintln(term.h_divider('-'))
}
//
pub fn (r NormalReporter) worker_threads_start(files []string, mut ts TestSession) {
// eprintln('> ${@METHOD}')
}
pub fn (r NormalReporter) worker_threads_finish(mut ts TestSession) {
// eprintln('> ${@METHOD}')
}
pub fn (r NormalReporter) list_of_failed_commands(failed_cmds []string) {
for i, cmd in failed_cmds {
eprintln(term.failed('Failed command ${i + 1}:') + ' ${cmd}')
}
}

View File

@@ -0,0 +1,60 @@
module testing
// TeamcityReporter implements the interface `testing.Reporter`.
// It is used by `v -test-runner teamcity test .`
pub struct TeamcityReporter {
}
pub fn (r TeamcityReporter) session_start(message string, mut ts TestSession) {
}
pub fn (r TeamcityReporter) session_stop(message string, mut ts TestSession) {
}
pub fn (r TeamcityReporter) report(index int, message LogMessage) {
name := r.get_test_suite_name_by_file(message.file)
match message.kind {
.cmd_begin {
eprintln("##teamcity[testSuiteStarted name='${name}' flowId='${message.flow_id}']")
}
.cmd_end {
eprintln("##teamcity[testSuiteFinished name='${name}' flowId='${message.flow_id}' duration='${message.took}']")
}
.cannot_compile {
eprintln("##teamcity[testFailed name='${name}' message='${message.message}']")
}
else {}
}
}
pub fn (r TeamcityReporter) get_test_suite_name_by_file(path string) string {
file_name := path.replace('\\', '/').split('/').last()
return file_name.split('.').first()
}
pub fn (r TeamcityReporter) report_stop() {
}
pub fn (r TeamcityReporter) progress(index int, message string) {
}
pub fn (r TeamcityReporter) update_last_line(index int, message string) {
}
pub fn (r TeamcityReporter) update_last_line_and_move_to_next(index int, message string) {
}
pub fn (r TeamcityReporter) message(index int, message string) {
}
pub fn (r TeamcityReporter) divider() {
}
pub fn (r TeamcityReporter) worker_threads_start(files []string, mut ts TestSession) {
}
pub fn (r TeamcityReporter) worker_threads_finish(mut ts TestSession) {
}
pub fn (r TeamcityReporter) list_of_failed_commands(failed_cmds []string) {
}

View File

@@ -22,9 +22,9 @@ pub fn validate_commit_exists(commit string) {
if commit.len == 0 {
return
}
cmd := "git cat-file -t '$commit' "
cmd := "git cat-file -t '${commit}' "
if !scripting.exit_0_status(cmd) {
eprintln('Commit: "$commit" does not exist in the current repository.')
eprintln('Commit: "${commit}" does not exist in the current repository.')
exit(3)
}
}
@@ -50,39 +50,39 @@ pub fn prepare_vc_source(vcdir string, cdir string, commit string) (string, stri
// Building a historic v with the latest vc is not always possible ...
// It is more likely, that the vc *at the time of the v commit*,
// or slightly before that time will be able to build the historic v:
vline := scripting.run('git rev-list -n1 --timestamp "$commit" ')
vline := scripting.run('git rev-list -n1 --timestamp "${commit}" ')
v_timestamp, v_commithash := line_to_timestamp_and_commit(vline)
scripting.verbose_trace(@FN, 'v_timestamp: $v_timestamp | v_commithash: $v_commithash')
scripting.verbose_trace(@FN, 'v_timestamp: ${v_timestamp} | v_commithash: ${v_commithash}')
check_v_commit_timestamp_before_self_rebuilding(v_timestamp)
scripting.chdir(vcdir)
scripting.run('git checkout --quiet master')
//
mut vccommit := ''
vcbefore_subject_match := scripting.run('git rev-list HEAD -n1 --timestamp --grep=${v_commithash[0..7]} ')
scripting.verbose_trace(@FN, 'vcbefore_subject_match: $vcbefore_subject_match')
scripting.verbose_trace(@FN, 'vcbefore_subject_match: ${vcbefore_subject_match}')
if vcbefore_subject_match.len > 3 {
_, vccommit = line_to_timestamp_and_commit(vcbefore_subject_match)
} else {
scripting.verbose_trace(@FN, 'the v commit did not match anything in the vc log; try --timestamp instead.')
vcbefore := scripting.run('git rev-list HEAD -n1 --timestamp --before=$v_timestamp ')
vcbefore := scripting.run('git rev-list HEAD -n1 --timestamp --before=${v_timestamp} ')
_, vccommit = line_to_timestamp_and_commit(vcbefore)
}
scripting.verbose_trace(@FN, 'vccommit: $vccommit')
scripting.run('git checkout --quiet "$vccommit" ')
scripting.verbose_trace(@FN, 'vccommit: ${vccommit}')
scripting.run('git checkout --quiet "${vccommit}" ')
scripting.run('wc *.c')
scripting.chdir(cdir)
return v_commithash, vccommit
}
pub fn clone_or_pull(remote_git_url string, local_worktree_path string) {
// NB: after clone_or_pull, the current repo branch is === HEAD === master
// Note: after clone_or_pull, the current repo branch is === HEAD === master
if os.is_dir(local_worktree_path) && os.is_dir(os.join_path_single(local_worktree_path, '.git')) {
// Already existing ... Just pulling in this case is faster usually.
scripting.run('git -C "$local_worktree_path" checkout --quiet master')
scripting.run('git -C "$local_worktree_path" pull --quiet ')
scripting.run('git -C "${local_worktree_path}" checkout --quiet master')
scripting.run('git -C "${local_worktree_path}" pull --quiet ')
} else {
// Clone a fresh
scripting.run('git clone --quiet "$remote_git_url" "$local_worktree_path" ')
scripting.run('git clone --quiet "${remote_git_url}" "${local_worktree_path}" ')
}
}
@@ -111,17 +111,17 @@ pub fn (mut vgit_context VGitContext) compile_oldv_if_needed() {
mut command_for_building_v_from_c_source := ''
mut command_for_selfbuilding := ''
if 'windows' == os.user_os() {
command_for_building_v_from_c_source = '$vgit_context.cc -std=c99 -I ./thirdparty/stdatomic/win -municode -w -o cv.exe "$vgit_context.path_vc/v_win.c" '
command_for_selfbuilding = './cv.exe -o $vgit_context.vexename {SOURCE}'
command_for_building_v_from_c_source = '${vgit_context.cc} -std=c99 -I ./thirdparty/stdatomic/win -municode -w -o cv.exe "${vgit_context.path_vc}/v_win.c" '
command_for_selfbuilding = './cv.exe -o ${vgit_context.vexename} {SOURCE}'
} else {
command_for_building_v_from_c_source = '$vgit_context.cc -std=gnu11 -I ./thirdparty/stdatomic/nix -w -o cv "$vgit_context.path_vc/v.c" -lm -lpthread'
command_for_selfbuilding = './cv -o $vgit_context.vexename {SOURCE}'
command_for_building_v_from_c_source = '${vgit_context.cc} -std=gnu11 -I ./thirdparty/stdatomic/nix -w -o cv "${vgit_context.path_vc}/v.c" -lm -lpthread'
command_for_selfbuilding = './cv -o ${vgit_context.vexename} {SOURCE}'
}
scripting.chdir(vgit_context.workdir)
clone_or_pull(vgit_context.v_repo_url, vgit_context.path_v)
clone_or_pull(vgit_context.vc_repo_url, vgit_context.path_vc)
scripting.chdir(vgit_context.path_v)
scripting.run('git checkout --quiet $vgit_context.commit_v')
scripting.run('git checkout --quiet ${vgit_context.commit_v}')
if os.is_dir(vgit_context.path_v) && os.exists(vgit_context.vexepath) {
// already compiled, so no need to compile v again
vgit_context.commit_v__hash = get_current_folder_commit_hash()
@@ -163,7 +163,7 @@ pub mut:
pub fn add_common_tool_options(mut context VGitOptions, mut fp flag.FlagParser) []string {
tdir := os.temp_dir()
context.workdir = os.real_path(fp.string('workdir', `w`, context.workdir, 'A writable base folder. Default: $tdir'))
context.workdir = os.real_path(fp.string('workdir', `w`, context.workdir, 'A writable base folder. Default: ${tdir}'))
context.v_repo_url = fp.string('vrepo', 0, context.v_repo_url, 'The url of the V repository. You can clone it locally too. See also --vcrepo below.')
context.vc_repo_url = fp.string('vcrepo', 0, context.vc_repo_url, 'The url of the vc repository. You can clone it
${flag.space}beforehand, and then just give the local folder
@@ -187,7 +187,7 @@ ${flag.space}to script it/run it in a restrictive vps/docker.
context.vc_repo_url = os.real_path(context.vc_repo_url)
}
commits := fp.finalize() or {
eprintln('Error: $err')
eprintln('Error: ${err}')
exit(1)
}
for commit in commits {

View File

@@ -1,14 +0,0 @@
module vhelp
import os
pub fn show_topic(topic string) {
vexe := os.real_path(os.getenv('VEXE'))
vroot := os.dir(vexe)
target_topic := os.join_path(vroot, 'cmd', 'v', 'help', '${topic}.txt')
content := os.read_file(target_topic) or {
eprintln('Unknown topic: $topic')
exit(1)
}
println(content)
}

View File

@@ -16,7 +16,7 @@ const (
| git checkout known_good_commit
| git bisect good
| ## Now git will automatically checkout a middle commit between the bad and the good
| cmd/tools/oldv HEAD --command="run commands in oldv folder, to verify if the commit is good or bad"
| cmd/tools/oldv --bisect --command="run commands in oldv folder, to verify if the commit is good or bad"
| ## See what the result is, and either do: ...
| git bisect good
| ## ... or do:
@@ -40,6 +40,7 @@ mut:
cleanup bool // should the tool run a cleanup first
use_cache bool // use local cached copies for --vrepo and --vcrepo in
fresh_tcc bool // do use `make fresh_tcc`
is_bisect bool // bisect mode; usage: `cmd/tools/oldv -b -c './v run bug.v'`
}
fn (mut c Context) compile_oldv_if_needed() {
@@ -56,7 +57,7 @@ fn (mut c Context) compile_oldv_if_needed() {
c.vgcontext.compile_oldv_if_needed()
c.commit_v_hash = c.vgcontext.commit_v__hash
if !os.exists(c.vgcontext.vexepath) && c.cmd_to_run.len > 0 {
// NB: 125 is a special code, that git bisect understands as 'skip this commit'.
// Note: 125 is a special code, that git bisect understands as 'skip this commit'.
// it is used to inform git bisect that the current commit leads to a build failure.
exit(125)
}
@@ -71,7 +72,7 @@ const cache_oldv_folder_vc = os.join_path(cache_oldv_folder, 'vc')
fn sync_cache() {
scripting.verbose_trace(@FN, 'start')
if !os.exists(cache_oldv_folder) {
scripting.verbose_trace(@FN, 'creating $cache_oldv_folder')
scripting.verbose_trace(@FN, 'creating ${cache_oldv_folder}')
scripting.mkdir_all(cache_oldv_folder) or {
scripting.verbose_trace(@FN, '## failed.')
exit(1)
@@ -81,16 +82,16 @@ fn sync_cache() {
for reponame in ['v', 'vc'] {
repofolder := os.join_path(cache_oldv_folder, reponame)
if !os.exists(repofolder) {
scripting.verbose_trace(@FN, 'cloning to $repofolder')
scripting.exec('git clone --quiet https://github.com/vlang/$reponame $repofolder') or {
scripting.verbose_trace(@FN, '## error during clone: $err')
scripting.verbose_trace(@FN, 'cloning to ${repofolder}')
scripting.exec('git clone --quiet https://github.com/vlang/${reponame} ${repofolder}') or {
scripting.verbose_trace(@FN, '## error during clone: ${err}')
exit(1)
}
}
scripting.chdir(repofolder)
scripting.exec('git pull --quiet') or {
scripting.verbose_trace(@FN, 'pulling to $repofolder')
scripting.verbose_trace(@FN, '## error during pull: $err')
scripting.verbose_trace(@FN, 'pulling to ${repofolder}')
scripting.verbose_trace(@FN, '## error during pull: ${err}')
exit(1)
}
}
@@ -122,8 +123,9 @@ fn main() {
context.vgo.vc_repo_url = 'https://github.com/vlang/vc'
}
should_sync := fp.bool('cache-sync', `s`, false, 'Update the local cache')
if !should_sync {
fp.limit_free_args(1, 1) ?
context.is_bisect = fp.bool('bisect', `b`, false, 'Bisect mode. Use the current commit in the repo where oldv is.')
if !should_sync && !context.is_bisect {
fp.limit_free_args(1, 1)!
}
////
context.cleanup = fp.bool('clean', 0, false, 'Clean before running (slower).')
@@ -141,14 +143,18 @@ fn main() {
}
if commits.len > 0 {
context.commit_v = commits[0]
if context.is_bisect {
eprintln('In bisect mode, you should not pass any commits, since oldv will use the current one.')
exit(2)
}
} else {
context.commit_v = scripting.run('git rev-list -n1 HEAD')
}
scripting.cprintln('################# context.commit_v: $context.commit_v #####################')
scripting.cprintln('################# context.commit_v: ${context.commit_v} #####################')
context.path_v = vgit.normalized_workpath_for_commit(context.vgo.workdir, context.commit_v)
context.path_vc = vgit.normalized_workpath_for_commit(context.vgo.workdir, 'vc')
if !os.is_dir(context.vgo.workdir) {
eprintln('Work folder: $context.vgo.workdir , does not exist.')
eprintln('Work folder: ${context.vgo.workdir} , does not exist.')
exit(2)
}
ecc := os.getenv('CC')
@@ -162,7 +168,7 @@ fn main() {
context.compile_oldv_if_needed()
scripting.chdir(context.path_v)
shorter_hash := context.commit_v_hash[0..10]
scripting.cprintln('# v commit hash: $shorter_hash | folder: $context.path_v')
scripting.cprintln('# v commit hash: ${shorter_hash} | folder: ${context.path_v}')
if context.cmd_to_run.len > 0 {
scripting.cprintln_strong('# command: ${context.cmd_to_run:-34s}')
cmdres := os.execute_or_exit(context.cmd_to_run)

View File

@@ -37,10 +37,10 @@ fn (c Context) compare_versions() {
// Input is validated at this point...
// Cleanup artifacts from previous runs of this tool:
scripting.chdir(c.vgo.workdir)
scripting.run('rm -rf "$c.a" "$c.b" "$c.vc" ')
scripting.run('rm -rf "${c.a}" "${c.b}" "${c.vc}" ')
// clone the VC source *just once per comparison*, and reuse it:
scripting.run('git clone --quiet "$c.vgo.vc_repo_url" "$c.vc" ')
println('Comparing V performance of commit $c.commit_before (before) vs commit $c.commit_after (after) ...')
scripting.run('git clone --quiet "${c.vgo.vc_repo_url}" "${c.vc}" ')
println('Comparing V performance of commit ${c.commit_before} (before) vs commit ${c.commit_after} (after) ...')
c.prepare_v(c.b, c.commit_before)
c.prepare_v(c.a, c.commit_after)
scripting.chdir(c.vgo.workdir)
@@ -72,7 +72,7 @@ fn (c Context) compare_versions() {
])
println('All performance files:')
for f in perf_files {
println(' $f')
println(' ${f}')
}
}
@@ -92,11 +92,11 @@ fn (c &Context) prepare_v(cdir string, commit string) {
}
vgit_context.compile_oldv_if_needed()
scripting.chdir(cdir)
println('Making a v compiler in $cdir')
scripting.run('./v -cc $cc -o v $vgit_context.vvlocation')
println('Making a vprod compiler in $cdir')
scripting.run('./v -cc $cc -prod -o vprod $vgit_context.vvlocation')
println('Stripping and compressing cv v and vprod binaries in $cdir')
println('Making a v compiler in ${cdir}')
scripting.run('./v -cc ${cc} -o v ${vgit_context.vvlocation}')
println('Making a vprod compiler in ${cdir}')
scripting.run('./v -cc ${cc} -prod -o vprod ${vgit_context.vvlocation}')
println('Stripping and compressing cv v and vprod binaries in ${cdir}')
scripting.run('cp cv cv_stripped')
scripting.run('cp v v_stripped')
scripting.run('cp vprod vprod_stripped')
@@ -107,13 +107,13 @@ fn (c &Context) prepare_v(cdir string, commit string) {
scripting.run('upx -qqq --lzma cv_stripped_upxed')
scripting.run('upx -qqq --lzma v_stripped_upxed')
scripting.run('upx -qqq --lzma vprod_stripped_upxed')
scripting.show_sizes_of_files(['$cdir/cv', '$cdir/cv_stripped', '$cdir/cv_stripped_upxed'])
scripting.show_sizes_of_files(['$cdir/v', '$cdir/v_stripped', '$cdir/v_stripped_upxed'])
scripting.show_sizes_of_files(['$cdir/vprod', '$cdir/vprod_stripped',
'$cdir/vprod_stripped_upxed'])
vversion := scripting.run('$cdir/v -version')
scripting.show_sizes_of_files(['${cdir}/cv', '${cdir}/cv_stripped', '${cdir}/cv_stripped_upxed'])
scripting.show_sizes_of_files(['${cdir}/v', '${cdir}/v_stripped', '${cdir}/v_stripped_upxed'])
scripting.show_sizes_of_files(['${cdir}/vprod', '${cdir}/vprod_stripped',
'${cdir}/vprod_stripped_upxed'])
vversion := scripting.run('${cdir}/v -version')
vcommit := scripting.run('git rev-parse --short --verify HEAD')
println('V version is: $vversion , local source commit: $vcommit')
println('V version is: ${vversion} , local source commit: ${vcommit}')
if vgit_context.vvlocation == 'cmd/v' {
if os.exists('vlib/v/ast/ast.v') {
println('Source lines of the compiler: ' +
@@ -132,21 +132,21 @@ fn (c &Context) prepare_v(cdir string, commit string) {
fn (c Context) compare_v_performance(label string, commands []string) string {
println('---------------------------------------------------------------------------------')
println('Compare v performance when doing the following commands ($label):')
println('Compare v performance when doing the following commands (${label}):')
mut source_location_a := ''
mut source_location_b := ''
if os.exists('$c.a/cmd/v') {
if os.exists('${c.a}/cmd/v') {
source_location_a = 'cmd/v'
} else {
source_location_a = if os.exists('$c.a/v.v') { 'v.v ' } else { 'compiler/ ' }
source_location_a = if os.exists('${c.a}/v.v') { 'v.v ' } else { 'compiler/ ' }
}
if os.exists('$c.b/cmd/v') {
if os.exists('${c.b}/cmd/v') {
source_location_b = 'cmd/v'
} else {
source_location_b = if os.exists('$c.b/v.v') { 'v.v ' } else { 'compiler/ ' }
source_location_b = if os.exists('${c.b}/v.v') { 'v.v ' } else { 'compiler/ ' }
}
timestamp_a, _ := vgit.line_to_timestamp_and_commit(scripting.run('cd $c.a/ ; git rev-list -n1 --timestamp HEAD'))
timestamp_b, _ := vgit.line_to_timestamp_and_commit(scripting.run('cd $c.b/ ; git rev-list -n1 --timestamp HEAD'))
timestamp_a, _ := vgit.line_to_timestamp_and_commit(scripting.run('cd ${c.a}/ ; git rev-list -n1 --timestamp HEAD'))
timestamp_b, _ := vgit.line_to_timestamp_and_commit(scripting.run('cd ${c.b}/ ; git rev-list -n1 --timestamp HEAD'))
debug_option_a := if timestamp_a > 1570877641 { '-cg ' } else { '-debug ' }
debug_option_b := if timestamp_b > 1570877641 { '-cg ' } else { '-debug ' }
mut hyperfine_commands_arguments := []string{}
@@ -154,7 +154,7 @@ fn (c Context) compare_v_performance(label string, commands []string) string {
println(cmd)
}
for cmd in commands {
hyperfine_commands_arguments << ' \'cd ${c.b:-34s} ; ./$cmd \' '.replace_each([
hyperfine_commands_arguments << ' \'cd ${c.b:-34s} ; ./${cmd} \' '.replace_each([
'@COMPILER@',
source_location_b,
'@DEBUG@',
@@ -162,7 +162,7 @@ fn (c Context) compare_v_performance(label string, commands []string) string {
])
}
for cmd in commands {
hyperfine_commands_arguments << ' \'cd ${c.a:-34s} ; ./$cmd \' '.replace_each([
hyperfine_commands_arguments << ' \'cd ${c.a:-34s} ; ./${cmd} \' '.replace_each([
'@COMPILER@',
source_location_a,
'@DEBUG@',
@@ -171,15 +171,15 @@ fn (c Context) compare_v_performance(label string, commands []string) string {
}
// /////////////////////////////////////////////////////////////////////////////
cmd_stats_file := os.real_path([c.vgo.workdir, 'v_performance_stats_${label}.json'].join(os.path_separator))
comparison_cmd := 'hyperfine $c.hyperfineopts ' + '--export-json $cmd_stats_file ' +
'--time-unit millisecond ' + '--style full --warmup $c.warmups ' +
comparison_cmd := 'hyperfine ${c.hyperfineopts} ' + '--export-json ${cmd_stats_file} ' +
'--time-unit millisecond ' + '--style full --warmup ${c.warmups} ' +
hyperfine_commands_arguments.join(' ')
// /////////////////////////////////////////////////////////////////////////////
if c.vgo.verbose {
println(comparison_cmd)
}
os.system(comparison_cmd)
println('The detailed performance comparison report was saved to: $cmd_stats_file .')
println('The detailed performance comparison report was saved to: ${cmd_stats_file} .')
println('')
return cmd_stats_file
}
@@ -194,11 +194,11 @@ fn main() {
fp.description(tool_description)
fp.arguments_description('COMMIT_BEFORE [COMMIT_AFTER]')
fp.skip_executable()
fp.limit_free_args(1, 2) ?
fp.limit_free_args(1, 2)!
context.vflags = fp.string('vflags', 0, '', 'Additional options to pass to the v commands, for example "-cc tcc"')
context.hyperfineopts = fp.string('hyperfine_options', 0, '', 'Additional options passed to hyperfine.
${flag.space}For example on linux, you may want to pass:
$flag.space--hyperfine_options "--prepare \'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches\'"
${flag.space}--hyperfine_options "--prepare \'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches\'"
')
commits := vgit.add_common_tool_options(mut context.vgo, mut fp)
context.commit_before = commits[0]

79
cmd/tools/regress.v Normal file
View File

@@ -0,0 +1,79 @@
import os
import term
import flag
const tools_folder = os.real_path(os.dir(os.executable()))
const oldvexe = fullpath(tools_folder, 'oldv')
const oldv_source = fullpath(tools_folder, 'oldv.v')
const vroot = os.real_path(os.dir(os.dir(tools_folder)))
const vexe = fullpath(vroot, 'v')
fn fullpath(folder string, fname string) string {
return os.real_path(os.join_path_single(folder, exename(fname)))
}
fn exename(n string) string {
if n.ends_with('.v') || os.user_os() != 'windows' {
return n
}
return '${n}.exe'
}
struct Context {
mut:
old_commit string
new_commit string
command string
}
fn main() {
mut fp := flag.new_flag_parser(os.args)
mut context := Context{}
fp.application(os.file_name(os.executable()))
fp.version('0.0.2')
fp.description('\n Find at what commit a regression occurred.
To find when a regression happened (regression_bug.v should fail on master):
./v run cmd/tools/regress.v --old a7019ac --command " ./v run /abs/path/to/regression_bug.v"
To find when a feature was implemented (feature.v should succeed on master):
./v run cmd/tools/regress.v --old a7019ac --command "! ./v run /abs/path/to/feature.v"')
fp.skip_executable()
//
context.new_commit = fp.string('new', `n`, 'master', 'The new commit, by default: master.')
context.old_commit = fp.string('old', `o`, '', 'A known old commit, required (for it, COMMAND should exit with 0).')
context.command = fp.string('command', `c`, '', 'A command to execute. Should exit with 0 for the *old* commits.')
fp.finalize() or {}
if context.old_commit == '' {
eprintln('--old COMMIT is required')
exit(1)
}
if context.command == '' {
eprintln('--command "COMMAND" is required')
exit(2)
}
if !os.exists(oldvexe) {
if 0 != execute('${os.quoted_path(vexe)} -o ${os.quoted_path(oldvexe)} ${os.quoted_path(oldv_source)}') {
panic('can not compile ${oldvexe}')
}
}
os.execute('git checkout master')
os.execute('git bisect reset')
os.execute('git checkout ${context.new_commit}')
os.execute('git bisect start')
os.execute('git bisect new')
os.execute('git checkout ${context.old_commit}')
os.execute('git bisect old')
println(term.colorize(term.bright_yellow, term.header('', '-')))
execute('git bisect run ${os.quoted_path(oldvexe)} --bisect -c "${context.command}"')
println(term.colorize(term.bright_yellow, term.header('', '-')))
os.execute('git bisect reset')
os.execute('git checkout master')
}
fn execute(cmd string) int {
eprintln('### ${cmd}')
return os.system(cmd)
}

View File

@@ -143,25 +143,25 @@ const (
fn main() {
mut context := Context{}
context.parse_options() ?
context.parse_options()!
context.run()
context.show_diff_summary()
}
fn (mut context Context) parse_options() ? {
fn (mut context Context) parse_options() ! {
mut fp := flag.new_flag_parser(os.args)
fp.application(os.file_name(os.executable()))
fp.version('0.0.1')
fp.description('Repeat command(s) and collect statistics. NB: you have to quote each command, if it contains spaces.')
fp.description('Repeat command(s) and collect statistics. Note: you have to quote each command, if it contains spaces.')
fp.arguments_description('CMD1 CMD2 ...')
fp.skip_executable()
fp.limit_free_args_to_at_least(1) ?
fp.limit_free_args_to_at_least(1)!
context.count = fp.int('count', `c`, 10, 'Repetition count.')
context.series = fp.int('series', `s`, 2, 'Series count. `-s 2 -c 4 a b` => aaaabbbbaaaabbbb, while `-s 3 -c 2 a b` => aabbaabbaabb.')
context.warmup = fp.int('warmup', `w`, 2, 'Warmup runs. These are done *only at the start*, and are ignored.')
context.show_help = fp.bool('help', `h`, false, 'Show this help screen.')
context.use_newline = fp.bool('newline', `n`, false, 'Use \\n, do not overwrite the last line. Produces more output, but easier to diagnose.')
context.show_output = fp.bool('output', `O`, false, 'Show command stdout/stderr in the progress indicator for each command. NB: slower, for verbose commands.')
context.show_output = fp.bool('output', `O`, false, 'Show command stdout/stderr in the progress indicator for each command. Note: slower, for verbose commands.')
context.verbose = fp.bool('verbose', `v`, false, 'Be more verbose.')
context.fail_on_maxtime = fp.int('max_time', `m`, max_time, 'Fail with exit code 2, when first cmd takes above M milliseconds (regression).')
context.fail_on_regress_percent = fp.int('fail_percent', `f`, max_fail_percent, 'Fail with exit code 3, when first cmd is X% slower than the rest (regression).')
@@ -183,7 +183,7 @@ fn (mut context Context) parse_options() ? {
scripting.set_verbose(true)
}
commands := fp.finalize() or {
eprintln('Error: $err')
eprintln('Error: ${err}')
exit(1)
}
context.commands = context.expand_all_commands(commands)
@@ -200,8 +200,13 @@ fn (mut context Context) parse_options() ? {
}
}
fn flushed_print(s string) {
print(s)
flush_stdout()
}
fn (mut context Context) clear_line() {
print(context.cline)
flushed_print(context.cline)
}
fn (mut context Context) expand_all_commands(commands []string) []string {
@@ -244,10 +249,10 @@ fn (mut context Context) run() {
mut duration := 0
mut sum := 0
mut oldres := ''
println('Series: ${si:4}/${context.series:-4}, command: $cmd')
println('Series: ${si:4}/${context.series:-4}, command: ${cmd}')
if context.warmup > 0 && run_warmups < context.commands.len {
for i in 1 .. context.warmup + 1 {
print('${context.cgoback}warming up run: ${i:4}/${context.warmup:-4} for ${cmd:-50s} took ${duration:6} ms ...')
flushed_print('${context.cgoback}warming up run: ${i:4}/${context.warmup:-4} for ${cmd:-50s} took ${duration:6} ms ...')
mut sw := time.new_stopwatch()
res := os.execute(cmd)
if res.exit_code != 0 {
@@ -260,15 +265,15 @@ fn (mut context Context) run() {
context.clear_line()
for i in 1 .. (context.count + 1) {
avg := f64(sum) / f64(i)
print('${context.cgoback}Average: ${avg:9.3f}ms | run: ${i:4}/${context.count:-4} | took ${duration:6} ms')
flushed_print('${context.cgoback}Average: ${avg:9.3f}ms | run: ${i:4}/${context.count:-4} | took ${duration:6} ms')
if context.show_output {
print(' | result: ${oldres:s}')
flushed_print(' | result: ${oldres:s}')
}
mut sw := time.new_stopwatch()
res := scripting.exec(cmd) or { continue }
duration = int(sw.elapsed().milliseconds())
if res.exit_code != 0 {
eprintln('${i:10} non 0 exit code for cmd: $cmd')
eprintln('${i:10} non 0 exit code for cmd: ${cmd}')
continue
}
trimed_output := res.output.trim_right('\r\n')
@@ -288,7 +293,7 @@ fn (mut context Context) run() {
context.results[icmd].atiming = new_aints(context.results[icmd].timings, context.nmins,
context.nmaxs)
context.clear_line()
print(context.cgoback)
flushed_print(context.cgoback)
mut m := map[string][]int{}
ioutputs := context.results[icmd].outputs
for o in ioutputs {
@@ -303,7 +308,7 @@ fn (mut context Context) run() {
for k, v in m {
// show a temporary summary for the current series/cmd cycle
s := new_aints(v, context.nmins, context.nmaxs)
println(' $k: $s')
println(' ${k}: ${s}')
summary[k] = s
}
// merge current raw results to the previous ones
@@ -341,7 +346,7 @@ fn (mut context Context) show_diff_summary() {
}
return 0
})
println('Summary (commands are ordered by ascending mean time), after $context.series series of $context.count repetitions:')
println('Summary (commands are ordered by ascending mean time), after ${context.series} series of ${context.count} repetitions:')
base := context.results[0].atiming.average
mut first_cmd_percentage := f64(100.0)
mut first_marker := ''
@@ -352,14 +357,14 @@ fn (mut context Context) show_diff_summary() {
first_marker = bold('>')
first_cmd_percentage = cpercent
}
println(' $first_marker${(i + 1):3} | ${cpercent:5.1f}% slower | ${r.cmd:-57s} | $r.atiming')
println(' ${first_marker}${(i + 1):3} | ${cpercent:5.1f}% slower | ${r.cmd:-57s} | ${r.atiming}')
}
$if debugcontext ? {
println('context: $context')
println('context: ${context}')
}
if int(base) > context.fail_on_maxtime {
print(performance_regression_label)
println('average time: ${base:6.1f} ms > $context.fail_on_maxtime ms threshold.')
flushed_print(performance_regression_label)
println('average time: ${base:6.1f} ms > ${context.fail_on_maxtime} ms threshold.')
exit(2)
}
if context.fail_on_regress_percent == max_fail_percent || context.results.len < 2 {
@@ -367,7 +372,7 @@ fn (mut context Context) show_diff_summary() {
}
fail_threshold_max := f64(context.fail_on_regress_percent)
if first_cmd_percentage > fail_threshold_max {
print(performance_regression_label)
flushed_print(performance_regression_label)
println('${first_cmd_percentage:5.1f}% > ${fail_threshold_max:5.1f}% threshold.')
exit(3)
}

View File

@@ -0,0 +1,68 @@
module main
import os
const vexe = @VEXE
const known_skip_patterns_env = os.getenv('VKNOWN_SKIP_PATTERNS')
const known_folder_patterns_that_are_not_module_ones = [
'vlib/sync/bench',
'/tests',
'/testdata',
'/preludes_js',
'vlib/builtin/js', // TODO: fix compiler panic
'vlib/fontstash', // used by `gg`
'vlib/sokol/sfons', // used by `gg`, and by examples/sokol/fonts.v
'vlib/sokol/sapp', // used by `gg`, and many examples/
'vlib/sokol/gfx', // used by `gg`, `x.ttf`
'vlib/sokol/sgl', // used by `gg`
'vlib/toml', // toml is well tested, even if the top level folder does not have _test.v files, the ones below do
'vlib/v/', // the compiler itself is well tested
]
fn main() {
mut places := if os.args.len > 1 {
os.args#[1..]
} else {
eprintln('> check the current folder only by default ...')
['.']
}
mut known_skip_patterns := known_folder_patterns_that_are_not_module_ones.clone()
if known_skip_patterns_env != '' {
known_skip_patterns = known_skip_patterns_env.split(',').filter(it != '')
}
for path in places {
eprintln('> Checking folder: `${path}` ...')
mut found := 0
files := os.walk_ext(path, '.v')
mut v_files := map[string]int{}
mut v_test_files := map[string]int{}
for f in files {
folder := os.to_slash(os.dir(f))
if known_skip_patterns.any(f.contains(it)) {
continue
}
if f.ends_with('.v') {
v_files[folder]++
}
if f.ends_with('_test.v') {
v_test_files[folder]++
}
}
eprintln('> Found ${v_files.len:5} potential V module folders (containing .v files).')
for folder, n_v_files in v_files {
n_test_v_files := v_test_files[folder]
if n_v_files > 1 && n_test_v_files == 0 {
println('> ${n_test_v_files:5} _test.v files, with ${n_v_files:5} .v files, in folder: ${folder}')
compilation := os.execute('${os.quoted_path(vexe)} -shared -W -Wfatal-errors -check ${os.quoted_path(folder)}')
if compilation.exit_code != 0 {
eprintln('> ${folder} has parser/checker errors!')
eprintln(compilation.output)
}
found++
}
}
eprintln('> Found ${found} module folders without _test.v files in `${path}` .')
}
}

View File

@@ -6,7 +6,7 @@ import os
import rand
const (
vexe = get_vexe_path()
vexe = os.quoted_path(get_vexe_path())
vroot = os.dir(vexe)
tdir = new_tdir()
)
@@ -17,7 +17,7 @@ fn get_vexe_path() string {
return env_vexe
}
me := os.executable()
eprintln('me: $me')
eprintln('me: ${me}')
mut vexe_ := os.join_path(os.dir(os.dir(os.dir(me))), 'v')
if os.user_os() == 'windows' {
vexe_ += '.exe'
@@ -26,63 +26,110 @@ fn get_vexe_path() string {
}
fn new_tdir() string {
tdir_ := os.join_path(os.temp_dir(), rand.ulid())
if os.exists(tdir_) {
os.rmdir(tdir_) or { panic(err) }
}
os.mkdir(tdir_) or { panic(err) }
dir := os.join_path(os.vtmp_dir(), 'v', rand.ulid())
os.rmdir_all(dir) or {}
os.mkdir_all(dir) or { panic(err) }
C.atexit(cleanup_tdir)
return tdir_
return dir
}
fn cleanup_tdir() {
println('... removing tdir: $tdir')
println('... removing tdir: ${tdir}')
os.rmdir_all(tdir) or { eprintln(err) }
}
fn create_test(tname string, tcontent string) ?string {
type MyResult = string
[noreturn]
fn (result MyResult) fail(reason string) {
eprintln('> ${reason}, but it does not. Result:\n${result}')
exit(1)
}
fn (result MyResult) has(sub string) MyResult {
if !result.contains(sub) {
result.fail(' result should have the substring `${sub}`')
}
return result
}
fn (result MyResult) matches(gpattern string) MyResult {
if !result.match_glob(gpattern) {
result.fail('result should match the glob pattern `${gpattern}`')
}
return result
}
fn create_test(tname string, tcontent string) !string {
tpath := os.join_path(tdir, tname)
os.write_file(tpath, tcontent) ?
eprintln('>>>>>>>> tpath: $tpath | tcontent: $tcontent')
return tpath
os.write_file(tpath, tcontent)!
eprintln('>>>>>>>> tpath: ${tpath} | tcontent: ${tcontent}')
return os.quoted_path(tpath)
}
fn check_assert_continues_works() ! {
os.chdir(tdir)!
create_test('assert_continues_option_works_test.v', 'fn test_fail1() { assert 2==4\nassert 2==1\nassert 2==0 }\nfn test_ok(){ assert true }\nfn test_fail2() { assert false }')!
result := check_fail('${vexe} -assert continues assert_continues_option_works_test.v')
result.has('assert_continues_option_works_test.v:1: fn test_fail1')
result.has('assert_continues_option_works_test.v:2: fn test_fail1')
result.has('assert_continues_option_works_test.v:3: fn test_fail1')
result.has('assert_continues_option_works_test.v:5: fn test_fail2')
result.has('> assert 2 == 4').has('> assert 2 == 1').has('> assert 2 == 0')
// Check if a test function, tagged with [assert_continues], has the same behaviour, without needing additional options
create_test('assert_continues_tag_works_test.v', '[assert_continues]fn test_fail1() { assert 2==4\nassert 2==1\nassert 2==0 }\nfn test_ok(){ assert true }\nfn test_fail2() { assert false\n assert false }')!
tag_res := check_fail('${vexe} assert_continues_tag_works_test.v')
tag_res.has('assert_continues_tag_works_test.v:1: fn test_fail1')
tag_res.has('assert_continues_tag_works_test.v:2: fn test_fail1')
tag_res.has('assert_continues_tag_works_test.v:3: fn test_fail1')
tag_res.has('assert_continues_tag_works_test.v:5: fn test_fail2')
if tag_res.contains('assert_continues_tag_works_test.v:6: fn test_fail2') {
exit(1)
}
}
fn check_ok(cmd string) MyResult {
println('> check_ok cmd: ${cmd}')
res := os.execute(cmd)
if res.exit_code != 0 {
eprintln('> check_ok failed.\n${res.output}')
exit(1)
}
return res.output
}
fn check_fail(cmd string) MyResult {
println('> check_fail cmd: ${cmd}')
res := os.execute(cmd)
if res.exit_code == 0 {
eprintln('> check_fail succeeded, but it should have failed.\n${res.output}')
exit(1)
}
return res.output
}
fn main() {
defer {
os.chdir(os.wd_at_startup) or {}
}
println('> vroot: $vroot | vexe: $vexe | tdir: $tdir')
ok_fpath := create_test('a_single_ok_test.v', 'fn test_ok(){ assert true }') ?
check_ok('"$vexe" "$ok_fpath"')
check_ok('"$vexe" test "$ok_fpath"')
check_ok('"$vexe" test "$tdir"')
fail_fpath := create_test('a_single_failing_test.v', 'fn test_fail(){ assert 1 == 2 }') ?
check_fail('"$vexe" "$fail_fpath"')
check_fail('"$vexe" test "$fail_fpath"')
check_fail('"$vexe" test "$tdir"')
println('> vroot: ${vroot} | vexe: ${vexe} | tdir: ${tdir}')
ok_fpath := create_test('a_single_ok_test.v', 'fn test_ok(){ assert true }')!
if check_ok('${vexe} ${ok_fpath}') != '' {
exit(1)
}
check_ok('${vexe} test ${ok_fpath}').matches('*OK*a_single_ok_test.v*')
check_ok('${vexe} test "${tdir}"').matches('*OK*a_single_ok_test.v*')
//
fail_fpath := create_test('a_single_failing_test.v', 'fn test_fail(){ assert 1 == 2 }')!
check_fail('${vexe} ${fail_fpath}').has('> assert 1 == 2').has('a_single_failing_test.v:1: fn test_fail')
check_fail('${vexe} test ${fail_fpath}').has('> assert 1 == 2').has('a_single_failing_test.v:1: fn test_fail')
check_fail('${vexe} test "${tdir}"').has('> assert 1 == 2')
rel_dir := os.join_path(tdir, rand.ulid())
os.mkdir(rel_dir) ?
os.chdir(rel_dir) ?
check_ok('"$vexe" test "..${os.path_separator + os.base(ok_fpath)}"')
os.mkdir(rel_dir)!
os.chdir(rel_dir)!
relative_path := '..' + os.path_separator + 'a_single_ok_test.v'
check_ok('${vexe} test ${os.quoted_path(relative_path)}').has('OK').has('a_single_ok_test.v')
//
check_assert_continues_works()!
println('> all done')
}
fn check_ok(cmd string) string {
println('> check_ok cmd: $cmd')
res := os.execute(cmd)
if res.exit_code != 0 {
eprintln('> check_ok failed.\n$res.output')
exit(1)
}
return res.output
}
fn check_fail(cmd string) string {
println('> check_fail cmd: $cmd')
res := os.execute(cmd)
if res.exit_code == 0 {
eprintln('> check_fail succeeded, but it should have failed.\n$res.output')
exit(1)
}
return res.output
}

View File

@@ -28,6 +28,8 @@ mut:
target Target
omode Target
is_verbose bool
show_wd bool
show_env bool
}
fn (mut ctx Context) println(s string) {
@@ -35,10 +37,10 @@ fn (mut ctx Context) println(s string) {
ctx.omode = if ctx.omode == .stderr { Target.stdout } else { Target.stderr }
}
if ctx.target in [.both, .stdout] || ctx.omode == .stdout {
println('stdout, $s')
println('stdout, ${s}')
}
if ctx.target in [.both, .stderr] || ctx.omode == .stderr {
eprintln('stderr, $s')
eprintln('stderr, ${s}')
}
}
@@ -53,7 +55,7 @@ fn main() {
args := os.args[1..]
if '-h' in args || '--help' in args {
println("Usage:
test_os_process [-v] [-h] [-target stderr/stdout/both/alternate] [-exitcode 0] [-timeout_ms 200] [-period_ms 50]
test_os_process [-v] [-h] [-target stderr/stdout/both/alternate] [-show_wd] [-show_env] [-exitcode 0] [-timeout_ms 200] [-period_ms 50]
Prints lines periodically (-period_ms), to stdout/stderr (-target).
After a while (-timeout_ms), exit with (-exitcode).
This program is useful for platform independent testing
@@ -63,6 +65,8 @@ fn main() {
return
}
ctx.is_verbose = '-v' in args
ctx.show_wd = '-show_wd' in args
ctx.show_env = '-show_env' in args
ctx.target = s2target(cmdline.option(args, '-target', 'both'))
ctx.exitcode = cmdline.option(args, '-exitcode', '0').int()
ctx.timeout_ms = cmdline.option(args, '-timeout_ms', '200').int()
@@ -71,11 +75,20 @@ fn main() {
ctx.omode = .stdout
}
if ctx.is_verbose {
eprintln('> args: $args | context: $ctx')
eprintln('> args: ${args} | context: ${ctx}')
}
go do_timeout(&ctx)
if ctx.show_wd {
ctx.println('WORK_DIR=${os.getwd()}')
}
if ctx.show_env {
all := os.environ()
for k, v in all {
ctx.println('${k}=${v}')
}
}
spawn do_timeout(&ctx)
for i := 1; true; i++ {
ctx.println('$i')
ctx.println('${i}')
time.sleep(ctx.period_ms * time.millisecond)
}
time.sleep(100 * time.second)

53
cmd/tools/translate.v Normal file
View File

@@ -0,0 +1,53 @@
// Copyright (c) 2019-2023 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license that can be found in the LICENSE file.
module main
import os
import v.util
const vexe = os.getenv('VEXE')
fn main() {
vmodules := os.vmodules_dir()
c2v_dir := os.join_path(vmodules, 'c2v')
mut c2v_bin := os.join_path(c2v_dir, 'c2v')
$if windows {
c2v_bin += '.exe'
}
// Git clone c2v
if !os.exists(c2v_dir) {
os.mkdir_all(vmodules)!
println('C2V is not installed. Cloning C2V to ${c2v_dir} ...')
os.chdir(vmodules)!
res := os.execute('git clone https://github.com/vlang/c2v')
if res.exit_code != 0 {
eprintln('Failed to download C2V.')
exit(1)
}
}
// Compile c2v
if !os.exists(c2v_bin) {
os.chdir(c2v_dir)!
println('Compiling c2v ...')
res2 := os.execute('${os.quoted_path(vexe)} -o ${os.quoted_path(c2v_bin)} -keepc -g -experimental .')
if res2.exit_code != 0 {
eprintln(res2.output)
eprintln('Failed to compile C2V. This should not happen. Please report it via GitHub.')
exit(2)
}
}
if os.args.len < 3 {
eprintln('Wrong number of arguments. Use `v translate file.c` .')
exit(3)
}
passed_args := util.args_quote_paths(os.args[2..])
// println(passed_args)
os.chdir(os.wd_at_startup)!
c2v_cmd := '${os.quoted_path(c2v_bin)} ${passed_args}'
res := os.system(c2v_cmd)
if res != 0 {
eprintln('C2V command: ${c2v_cmd}')
eprintln('C2V failed to translate the C files. Please report it via GitHub.')
exit(4)
}
}

View File

@@ -24,7 +24,7 @@ fn C.cJSON_CreateNull() &C.cJSON
// fn C.cJSON_CreateNumber() &C.cJSON
// fn C.cJSON_CreateString() &C.cJSON
fn C.cJSON_CreateRaw(&byte) &C.cJSON
fn C.cJSON_CreateRaw(&u8) &C.cJSON
fn C.cJSON_IsInvalid(voidptr) bool
@@ -45,13 +45,13 @@ fn C.cJSON_IsObject(voidptr) bool
fn C.cJSON_IsRaw(voidptr) bool
fn C.cJSON_AddItemToObject(voidptr, &byte, voidptr)
fn C.cJSON_AddItemToObject(voidptr, &u8, voidptr)
fn C.cJSON_AddItemToArray(voidptr, voidptr)
fn C.cJSON_Delete(voidptr)
fn C.cJSON_Print(voidptr) &byte
fn C.cJSON_Print(voidptr) &u8
[inline]
fn create_object() &C.cJSON {
@@ -108,7 +108,7 @@ fn add_item_to_array(obj &C.cJSON, item &C.cJSON) {
C.cJSON_AddItemToArray(obj, item)
}
fn json_print(json &C.cJSON) string {
s := C.cJSON_Print(json)
fn json_print(json_ &C.cJSON) string {
s := C.cJSON_Print(json_)
return unsafe { tos3(s) }
}

View File

@@ -109,23 +109,23 @@ fn defer_fn() {
}
// generic function
fn g_fn<T>(p T) T {
fn g_fn[T](p T) T {
return p
}
// generic struct
struct GenericStruct<T> {
struct GenericStruct[T] {
point Point
mut:
model T
}
// generic interface
interface Gettable<T> {
interface Gettable[T] {
get() T
}
// generic sumtype
struct None {}
type MyOption<T> = Error | None | T
type MyOption[T] = Error | None | T

View File

@@ -44,7 +44,7 @@ fn main() {
for hf in hfields.split(',') {
ctx.hide_names[hf] = true
}
fp.limit_free_args_to_at_least(1) ?
fp.limit_free_args_to_at_least(1)!
rest_of_args := fp.remaining_parameters()
for vfile in rest_of_args {
file := get_abs_path(vfile)
@@ -60,7 +60,7 @@ fn (ctx Context) write_file_or_print(file string) {
if ctx.is_print {
println(json(file))
} else {
println('$time.now(): AST written to: ' + json_file(file))
println('${time.now()}: AST written to: ' + json_file(file))
}
}
@@ -74,7 +74,7 @@ fn (ctx Context) watch_for_changes(file string) {
ctx.write_file_or_print(file)
if ctx.is_compile {
file_name := file[0..(file.len - os.file_ext(file).len)]
os.system('v -o ${file_name}.c $file')
os.system('v -o ${file_name}.c ${file}')
}
}
timestamp = new_timestamp
@@ -96,11 +96,11 @@ fn get_abs_path(path string) string {
// check file is v file and exists
fn check_file(file string) {
if os.file_ext(file) !in ['.v', '.vv', '.vsh'] {
eprintln('the file `$file` must be a v file or vsh file')
eprintln('the file `${file}` must be a v file or vsh file')
exit(1)
}
if !os.exists(file) {
eprintln('the v file `$file` does not exist')
eprintln('the v file `${file}` does not exist')
exit(1)
}
}
@@ -120,15 +120,15 @@ fn json(file string) string {
// use as permissive preferences as possible, so that `v ast`
// can print the AST of arbitrary V files, even .vsh or ones
// that require globals:
mut pref := &pref.Preferences{}
pref.fill_with_defaults()
pref.enable_globals = true
pref.is_fmt = true
mut pref_ := &pref.Preferences{}
pref_.fill_with_defaults()
pref_.enable_globals = true
pref_.is_fmt = true
//
mut t := Tree{
root: new_object()
table: ast.new_table()
pref: pref
pref: pref_
}
// parse file with comment
ast_file := parser.parse_file(file, t.table, .parse_comments, t.pref)
@@ -140,8 +140,8 @@ fn json(file string) string {
// the ast tree
struct Tree {
table &ast.Table
pref &pref.Preferences
table &ast.Table = unsafe { nil }
pref &pref.Preferences = unsafe { nil }
mut:
root Node // the root of tree
}
@@ -224,12 +224,12 @@ fn (t Tree) type_node(typ ast.Type) &Node {
// token type node
fn (t Tree) token_node(tok_kind token.Kind) &Node {
return t.string_node('token:${int(tok_kind)}($tok_kind.str())')
return t.string_node('token:${int(tok_kind)}(${tok_kind.str()})')
}
// enum type node
fn (t Tree) enum_node<T>(value T) &Node {
return t.string_node('enum:${int(value)}($value)')
fn (t Tree) enum_node[T](value T) &Node {
return t.string_node('enum:${int(value)}(${value})')
}
// for [][]comment
@@ -283,7 +283,7 @@ fn (t Tree) embed_file(node ast.EmbeddedFile) &Node {
obj.add('compression_type', t.string_node(node.compression_type))
obj.add('is_compressed', t.bool_node(node.is_compressed))
obj.add('len', t.number_node(node.len))
obj.add('bytes', t.array_node_byte(node.bytes))
obj.add('bytes', t.array_node_u8(node.bytes))
return obj
}
@@ -359,15 +359,14 @@ fn (t Tree) imports(nodes []ast.Import) &Node {
return import_array
}
fn (t Tree) errors(errors []errors.Error) &Node {
fn (t Tree) errors(errors_ []errors.Error) &Node {
mut errs := new_array()
for e in errors {
for e in errors_ {
obj := new_object()
obj.add_terse('message', t.string_node(e.message))
obj.add_terse('file_path', t.string_node(e.file_path))
obj.add('pos', t.pos(e.pos))
obj.add_terse('backtrace', t.string_node(e.backtrace))
obj.add_terse('reporter', t.enum_node(e.reporter))
obj.add('reporter', t.enum_node(e.reporter))
errs.add_item(obj)
}
return errs
@@ -377,8 +376,8 @@ fn (t Tree) warnings(warnings []errors.Warning) &Node {
mut warns := new_array()
for w in warnings {
mut obj := new_object()
obj.add('message', t.string_node(w.message))
obj.add('file_path', t.string_node(w.file_path))
obj.add_terse('message', t.string_node(w.message))
obj.add_terse('file_path', t.string_node(w.file_path))
obj.add('pos', t.pos(w.pos))
obj.add('reporter', t.enum_node(w.reporter))
warns.add_item(obj)
@@ -390,8 +389,8 @@ fn (t Tree) notices(notices []errors.Notice) &Node {
mut notice_array := new_array()
for n in notices {
mut obj := new_object()
obj.add('message', t.string_node(n.message))
obj.add('file_path', t.string_node(n.file_path))
obj.add_terse('message', t.string_node(n.message))
obj.add_terse('file_path', t.string_node(n.file_path))
obj.add('pos', t.pos(n.pos))
obj.add('reporter', t.enum_node(n.reporter))
notice_array.add_item(obj)
@@ -582,7 +581,11 @@ fn (t Tree) anon_fn(node ast.AnonFn) &Node {
obj.add_terse('decl', t.fn_decl(node.decl))
obj.add('inherited_vars', t.array_node_arg(node.inherited_vars))
obj.add_terse('typ', t.type_node(node.typ))
obj.add('has_gen', t.bool_node(node.has_gen))
symbol_obj := new_object()
for key, val in node.has_gen {
symbol_obj.add_terse(key.str(), t.bool_node(val))
}
obj.add_terse('has_gen', symbol_obj)
return obj
}
@@ -612,7 +615,10 @@ fn (t Tree) struct_field(node ast.StructField) &Node {
obj.add_terse('ast_type', t.string_node('StructField'))
obj.add_terse('name', t.string_node(node.name))
obj.add_terse('typ', t.type_node(node.typ))
obj.add_terse('anon_struct_decl', t.struct_decl(node.anon_struct_decl))
obj.add_terse('unaliased_typ', t.type_node(node.unaliased_typ))
obj.add('type_pos', t.pos(node.type_pos))
obj.add('option_pos', t.pos(node.option_pos))
obj.add_terse('has_default_expr', t.bool_node(node.has_default_expr))
obj.add_terse('default_expr_typ', t.type_node(node.default_expr_typ))
obj.add_terse('default_expr', t.expr(node.default_expr))
@@ -620,9 +626,11 @@ fn (t Tree) struct_field(node ast.StructField) &Node {
obj.add_terse('is_mut', t.bool_node(node.is_mut))
obj.add_terse('is_global', t.bool_node(node.is_global))
obj.add_terse('is_volatile', t.bool_node(node.is_volatile))
obj.add_terse('is_deprecated', t.bool_node(node.is_deprecated))
obj.add_terse('attrs', t.array_node_attr(node.attrs))
obj.add('comments', t.array_node_comment(node.comments))
obj.add('pos', t.pos(node.pos))
obj.add_terse('i', t.number_node(node.i))
return obj
}
@@ -645,6 +653,7 @@ fn (t Tree) enum_decl(node ast.EnumDecl) &Node {
obj.add_terse('fields', t.array_node_enum_field(node.fields))
obj.add('comments', t.array_node_comment(node.comments))
obj.add_terse('attrs', t.array_node_attr(node.attrs))
obj.add_terse('typ', t.type_node(node.typ))
return obj
}
@@ -674,8 +683,8 @@ fn (t Tree) interface_decl(node ast.InterfaceDecl) &Node {
obj.add('name_pos', t.pos(node.name_pos))
obj.add_terse('language', t.enum_node(node.language))
obj.add('pos', t.pos(node.pos))
obj.add('are_ifaces_expanded', t.bool_node(node.are_ifaces_expanded))
obj.add_terse('ifaces', t.array_node_interface_embedding(node.ifaces))
obj.add('are_embeds_expanded', t.bool_node(node.are_embeds_expanded))
obj.add_terse('embeds', t.array_node_interface_embedding(node.embeds))
obj.add_terse('attrs', t.array_node_attr(node.attrs))
return obj
}
@@ -779,8 +788,9 @@ fn (t Tree) alias_type_decl(node ast.AliasTypeDecl) &Node {
mut obj := new_object()
obj.add_terse('ast_type', t.string_node('AliasTypeDecl'))
obj.add_terse('name', t.string_node(node.name))
obj.add_terse('is_pub', t.bool_node(node.is_pub))
obj.add_terse('typ', t.type_node(node.typ))
obj.add_terse('parent_type', t.type_node(node.parent_type))
obj.add_terse('is_pub', t.bool_node(node.is_pub))
obj.add('comments', t.array_node_comment(node.comments))
obj.add('pos', t.pos(node.pos))
return obj
@@ -794,8 +804,8 @@ fn (t Tree) sum_type_decl(node ast.SumTypeDecl) &Node {
obj.add('pos', t.pos(node.pos))
obj.add_terse('typ', t.type_node(node.typ))
obj.add_terse('generic_types', t.array_node_type(node.generic_types))
obj.add('comments', t.array_node_comment(node.comments))
obj.add_terse('variants', t.array_node_type_expr(node.variants))
obj.add('name_pos', t.pos(node.name_pos))
return obj
}
@@ -823,6 +833,7 @@ fn (t Tree) goto_label(node ast.GotoLabel) &Node {
mut obj := new_object()
obj.add_terse('ast_type', t.string_node('GotoLabel'))
obj.add_terse('name', t.string_node(node.name))
obj.add_terse('is_used', t.bool_node(node.is_used))
obj.add('pos', t.pos(node.pos))
return obj
}
@@ -864,11 +875,13 @@ fn (t Tree) var(node ast.Var) &Node {
obj.add_terse('is_mut', t.bool_node(node.is_mut))
obj.add('is_used', t.bool_node(node.is_used))
obj.add('is_changed', t.bool_node(node.is_changed))
obj.add_terse('ct_type_var', t.enum_node(node.ct_type_var))
obj.add('is_or', t.bool_node(node.is_or))
obj.add('is_tmp', t.bool_node(node.is_tmp))
obj.add('is_autofree_tmp', t.bool_node(node.is_autofree_tmp))
obj.add('is_auto_deref', t.bool_node(node.is_auto_deref))
obj.add('is_inherited', t.bool_node(node.is_inherited))
obj.add('has_inherited', t.bool_node(node.has_inherited))
obj.add('is_auto_heap', t.bool_node(node.is_auto_heap))
obj.add('is_stack_obj', t.bool_node(node.is_stack_obj))
obj.add_terse('share', t.enum_node(node.share))
@@ -898,6 +911,7 @@ fn (t Tree) for_c_stmt(node ast.ForCStmt) &Node {
obj.add_terse('is_multi', t.bool_node(node.is_multi))
obj.add_terse('label', t.string_node(node.label))
obj.add('pos', t.pos(node.pos))
obj.add('comments', t.array_node_comment(node.comments))
obj.add('scope', t.number_node(int(node.scope)))
obj.add_terse('stmts', t.array_node_stmt(node.stmts))
return obj
@@ -910,6 +924,7 @@ fn (t Tree) for_stmt(node ast.ForStmt) &Node {
obj.add_terse('is_inf', t.bool_node(node.is_inf))
obj.add_terse('label', t.string_node(node.label))
obj.add('pos', t.pos(node.pos))
obj.add('comments', t.array_node_comment(node.comments))
obj.add('scope', t.number_node(int(node.scope)))
obj.add_terse('stmts', t.array_node_stmt(node.stmts))
return obj
@@ -928,8 +943,10 @@ fn (t Tree) for_in_stmt(node ast.ForInStmt) &Node {
obj.add_terse('cond_type', t.type_node(node.cond_type))
obj.add_terse('kind', t.enum_node(node.kind))
obj.add_terse('val_is_mut', t.bool_node(node.val_is_mut))
obj.add_terse('val_is_ref', t.bool_node(node.val_is_ref))
obj.add_terse('label', t.string_node(node.label))
obj.add('pos', t.pos(node.pos))
obj.add('comments', t.array_node_comment(node.comments))
obj.add('scope', t.number_node(int(node.scope)))
obj.add_terse('stmts', t.array_node_stmt(node.stmts))
return obj
@@ -949,6 +966,10 @@ fn (t Tree) assert_stmt(node ast.AssertStmt) &Node {
obj.add_terse('ast_type', t.string_node('AssertStmt'))
obj.add_terse('expr', t.expr(node.expr))
obj.add_terse('is_used', t.bool_node(node.is_used))
if node.extra !is ast.EmptyExpr {
obj.add_terse('extra', t.expr(node.extra))
obj.add('extra_pos', t.pos(node.extra_pos))
}
obj.add('pos', t.pos(node.pos))
return obj
}
@@ -980,6 +1001,7 @@ fn (t Tree) comptime_call(node ast.ComptimeCall) &Node {
obj.add_terse('env_value', t.string_node(node.env_value))
obj.add('pos', t.pos(node.pos))
obj.add_terse('args', t.array_node_call_arg(node.args))
obj.add_terse('or_block', t.or_expr(node.or_block))
return obj
}
@@ -1144,6 +1166,9 @@ fn (t Tree) expr(expr ast.Expr) &Node {
ast.GoExpr {
return t.go_expr(expr)
}
ast.SpawnExpr {
return t.spawn_expr(expr)
}
ast.OffsetOf {
return t.offset_of(expr)
}
@@ -1156,6 +1181,9 @@ fn (t Tree) expr(expr ast.Expr) &Node {
ast.EmptyExpr {
return t.empty_expr(expr)
}
ast.Nil {
return t.nil_expr(expr)
}
else {
// println('unknown expr')
return t.null_node()
@@ -1216,7 +1244,7 @@ fn (t Tree) string_inter_literal(node ast.StringInterLiteral) &Node {
obj.add_terse('pluss', t.array_node_bool(node.pluss))
obj.add_terse('fills', t.array_node_bool(node.fills))
obj.add_terse('fmt_poss', t.array_node_position(node.fmt_poss))
obj.add_terse('fmts', t.array_node_byte(node.fmts))
obj.add_terse('fmts', t.array_node_u8(node.fmts))
obj.add_terse('need_fmts', t.array_node_bool(node.need_fmts))
obj.add('pos', t.pos(node.pos))
return obj
@@ -1290,6 +1318,7 @@ fn (t Tree) type_expr(node ast.TypeNode) &Node {
fn (t Tree) size_of(node ast.SizeOf) &Node {
mut obj := new_object()
obj.add_terse('ast_type', t.string_node('SizeOf'))
obj.add_terse('guessed_type', t.bool_node(node.guessed_type))
obj.add_terse('is_type', t.bool_node(node.is_type))
obj.add_terse('typ', t.type_node(node.typ))
obj.add_terse('expr', t.expr(node.expr))
@@ -1300,6 +1329,7 @@ fn (t Tree) size_of(node ast.SizeOf) &Node {
fn (t Tree) is_ref_type(node ast.IsRefType) &Node {
mut obj := new_object()
obj.add_terse('ast_type', t.string_node('IsRefType'))
obj.add_terse('guessed_type', t.bool_node(node.guessed_type))
obj.add_terse('is_type', t.bool_node(node.is_type))
obj.add_terse('typ', t.type_node(node.typ))
obj.add_terse('expr', t.expr(node.expr))
@@ -1327,6 +1357,7 @@ fn (t Tree) infix_expr(node ast.InfixExpr) &Node {
obj.add_terse('left_type', t.type_node(node.left_type))
obj.add_terse('right', t.expr(node.right))
obj.add_terse('right_type', t.type_node(node.right_type))
obj.add_terse('promoted_type', t.type_node(node.promoted_type))
obj.add('auto_locked', t.string_node(node.auto_locked))
obj.add_terse('or_block', t.or_expr(node.or_block))
obj.add_terse('is_stmt', t.bool_node(node.is_stmt))
@@ -1358,6 +1389,7 @@ fn (t Tree) postfix_expr(node ast.PostfixExpr) &Node {
obj.add_terse('expr', t.expr(node.expr))
obj.add('auto_locked', t.string_node(node.auto_locked))
obj.add('pos', t.pos(node.pos))
obj.add('is_c2v_prefix', t.bool_node(node.is_c2v_prefix))
return obj
}
@@ -1369,8 +1401,10 @@ fn (t Tree) selector_expr(node ast.SelectorExpr) &Node {
obj.add_terse('field_name', t.string_node(node.field_name))
obj.add_terse('typ', t.type_node(node.typ))
obj.add_terse('name_type', t.type_node(node.name_type))
obj.add_terse('or_block', t.or_expr(node.or_block))
obj.add_terse('gkind_field', t.enum_node(node.gkind_field))
obj.add_terse('from_embed_types', t.array_node_type(node.from_embed_types))
obj.add_terse('has_hidden_receiver', t.bool_node(node.has_hidden_receiver))
obj.add_terse('next_token', t.token_node(node.next_token))
obj.add('pos', t.pos(node.pos))
obj.add('scope', t.number_node(int(node.scope)))
@@ -1384,6 +1418,7 @@ fn (t Tree) range_expr(node ast.RangeExpr) &Node {
obj.add_terse('high', t.expr(node.high))
obj.add_terse('has_high', t.bool_node(node.has_high))
obj.add_terse('has_low', t.bool_node(node.has_low))
obj.add_terse('typ', t.type_node(node.typ))
obj.add('pos', t.pos(node.pos))
return obj
}
@@ -1431,6 +1466,7 @@ fn (t Tree) ident(node ast.Ident) &Node {
obj.add('mut_pos', t.pos(node.mut_pos))
obj.add('obj', t.scope_object(node.obj))
obj.add('scope', t.number_node(int(node.scope)))
obj.add_terse('or_expr', t.or_expr(node.or_expr))
return obj
}
@@ -1448,7 +1484,7 @@ fn (t Tree) ident_var(node ast.IdentVar) &Node {
obj.add_terse('is_mut', t.bool_node(node.is_mut))
obj.add_terse('is_static', t.bool_node(node.is_static))
obj.add_terse('is_volatile', t.bool_node(node.is_volatile))
obj.add_terse('is_optional', t.bool_node(node.is_optional))
obj.add_terse('is_option', t.bool_node(node.is_option))
obj.add_terse('share', t.enum_node(node.share))
return obj
}
@@ -1465,12 +1501,17 @@ fn (t Tree) call_expr(node ast.CallExpr) &Node {
obj.add_terse('ast_type', t.string_node('CallExpr'))
obj.add_terse('mod', t.string_node(node.mod))
obj.add_terse('name', t.string_node(node.name))
obj.add_terse('const_name', t.string_node(node.const_name))
obj.add_terse('language', t.enum_node(node.language))
obj.add_terse('left_type', t.type_node(node.left_type))
obj.add_terse('receiver_type', t.type_node(node.receiver_type))
obj.add_terse('return_type', t.type_node(node.return_type))
obj.add_terse('fn_var_type', t.type_node(node.fn_var_type))
obj.add_terse('left', t.expr(node.left))
obj.add_terse('is_method', t.bool_node(node.is_method))
obj.add_terse('is_field', t.bool_node(node.is_field))
obj.add_terse('is_fn_var', t.bool_node(node.is_fn_var))
obj.add_terse('is_fn_a_const', t.bool_node(node.is_fn_a_const))
obj.add('is_keep_alive', t.bool_node(node.is_keep_alive))
obj.add_terse('is_noreturn', t.bool_node(node.is_noreturn))
obj.add_terse('is_ctor_new', t.bool_node(node.is_ctor_new))
@@ -1515,7 +1556,9 @@ fn (t Tree) struct_init(node ast.StructInit) &Node {
mut obj := new_object()
obj.add_terse('ast_type', t.string_node('StructInit'))
obj.add_terse('typ', t.type_node(node.typ))
obj.add_terse('is_short', t.bool_node(node.is_short))
obj.add_terse('no_keys', t.bool_node(node.no_keys))
obj.add_terse('is_short_syntax', t.bool_node(node.is_short_syntax))
obj.add_terse('is_anon', t.bool_node(node.is_anon))
obj.add_terse('unresolved', t.bool_node(node.unresolved))
obj.add_terse('has_update_expr', t.bool_node(node.has_update_expr))
obj.add_terse('update_expr', t.expr(node.update_expr))
@@ -1575,7 +1618,7 @@ fn (t Tree) array_init(node ast.ArrayInit) &Node {
obj.add_terse('has_len', t.bool_node(node.has_len))
obj.add_terse('has_cap', t.bool_node(node.has_cap))
obj.add_terse('has_default', t.bool_node(node.has_default))
obj.add_terse('has_it', t.bool_node(node.has_it))
obj.add_terse('has_index', t.bool_node(node.has_index))
obj.add_terse('expr_types', t.array_node_type(node.expr_types))
obj.add('pos', t.pos(node.pos))
return obj
@@ -1671,8 +1714,9 @@ fn (t Tree) concat_expr(node ast.ConcatExpr) &Node {
fn (t Tree) type_of(node ast.TypeOf) &Node {
mut obj := new_object()
obj.add_terse('ast_type', t.string_node('TypeOf'))
obj.add_terse('is_type', t.bool_node(node.is_type))
obj.add_terse('typ', t.type_node(node.typ))
obj.add_terse('expr', t.expr(node.expr))
obj.add_terse('expr_type', t.type_node(node.expr_type))
obj.add('pos', t.pos(node.pos))
return obj
}
@@ -1699,7 +1743,9 @@ fn (t Tree) sql_expr(node ast.SqlExpr) &Node {
obj.add_terse('order_expr', t.expr(node.order_expr))
obj.add_terse('has_desc', t.bool_node(node.has_desc))
obj.add_terse('is_array', t.bool_node(node.is_array))
obj.add_terse('or_expr', t.or_expr(node.or_expr))
obj.add('pos', t.pos(node.pos))
obj.add_terse('typ', t.type_node(node.typ))
obj.add_terse('has_limit', t.bool_node(node.has_limit))
obj.add_terse('limit_expr', t.expr(node.limit_expr))
obj.add_terse('has_offset', t.bool_node(node.has_offset))
@@ -1716,7 +1762,9 @@ fn (t Tree) sql_expr(node ast.SqlExpr) &Node {
fn (t Tree) sql_stmt(node ast.SqlStmt) &Node {
mut obj := new_object()
obj.add_terse('ast_type', t.string_node('SqlStmt'))
obj.add_terse('db_expr_type', t.type_node(node.db_expr_type))
obj.add_terse('db_expr', t.expr(node.db_expr))
obj.add_terse('or_expr', t.or_expr(node.or_expr))
obj.add('pos', t.pos(node.pos))
obj.add_terse('lines', t.array_node_sql_stmt_line(node.lines))
return obj
@@ -1770,6 +1818,7 @@ fn (t Tree) chan_init(expr ast.ChanInit) &Node {
obj.add_terse('typ', t.type_node(expr.typ))
obj.add_terse('elem_type', t.type_node(expr.elem_type))
obj.add('pos', t.pos(expr.pos))
obj.add('elem_type_pos', t.pos(expr.elem_type_pos))
return obj
}
@@ -1816,6 +1865,15 @@ fn (t Tree) go_expr(expr ast.GoExpr) &Node {
return obj
}
fn (t Tree) spawn_expr(expr ast.SpawnExpr) &Node {
mut obj := new_object()
obj.add_terse('ast_type', t.string_node('SpawnExpr'))
obj.add_terse('call_expr', t.call_expr(expr.call_expr))
obj.add_terse('is_expr', t.bool_node(expr.is_expr))
obj.add('pos', t.pos(expr.pos))
return obj
}
fn (t Tree) offset_of(expr ast.OffsetOf) &Node {
mut obj := new_object()
obj.add_terse('ast_type', t.string_node('OffsetOf'))
@@ -1856,6 +1914,13 @@ fn (t Tree) empty_stmt(node ast.EmptyStmt) &Node {
return obj
}
fn (t Tree) nil_expr(node ast.Nil) &Node {
mut obj := new_object()
obj.add_terse('ast_type', t.string_node('Nil'))
obj.add('pos', t.pos(node.pos))
return obj
}
fn (t Tree) asm_stmt(node ast.AsmStmt) &Node {
mut obj := new_object()
obj.add_terse('ast_type', t.string_node('AsmStmt'))
@@ -1978,7 +2043,7 @@ fn (t Tree) asm_io(node ast.AsmIO) &Node {
}
// do not support yet by vlang
// fn (t Tree) array_node1<T>(nodes []T, method_name string) &Node {
// fn (t Tree) array_node1[T](nodes []T, method_name string) &Node {
// mut arr := new_array()
// // call method dynamically, V do not support yet
@@ -2001,7 +2066,7 @@ fn (t Tree) asm_io(node ast.AsmIO) &Node {
// }
// do not support yet by vlang
// fn (t Tree) array_node2<T>(nodes []T) &Node {
// fn (t Tree) array_node2[T](nodes []T) &Node {
// mut arr := new_array()
// for node in nodes {
@@ -2209,7 +2274,7 @@ fn (t Tree) array_node_int(nodes []int) &Node {
return arr
}
fn (t Tree) array_node_byte(nodes []byte) &Node {
fn (t Tree) array_node_u8(nodes []u8) &Node {
mut arr := new_array()
for node in nodes {
arr.add_item(t.number_node(node))

View File

@@ -20,22 +20,22 @@ mut:
fn (context Context) header() string {
mut header_s := ''
header_s += 'module $context.module_name\n'
header_s += 'module ${context.module_name}\n'
header_s += '\n'
allfiles := context.files.join(' ')
mut options := []string{}
if context.prefix.len > 0 {
options << '-p $context.prefix'
options << '-p ${context.prefix}'
}
if context.module_name.len > 0 {
options << '-m $context.module_name'
options << '-m ${context.module_name}'
}
if context.write_file.len > 0 {
options << '-w $context.write_file'
options << '-w ${context.write_file}'
}
soptions := options.join(' ')
header_s += '// File generated by:\n'
header_s += '// v bin2v $allfiles $soptions\n'
header_s += '// v bin2v ${allfiles} ${soptions}\n'
header_s += '// Please, do not edit this file.\n'
header_s += '// Your changes may be overwritten.\n'
header_s += 'const (\n'
@@ -46,12 +46,12 @@ fn (context Context) footer() string {
return ')\n'
}
fn (context Context) file2v(bname string, fbytes []byte, bn_max int) string {
fn (context Context) file2v(bname string, fbytes []u8, bn_max int) string {
mut sb := strings.new_builder(1000)
bn_diff_len := bn_max - bname.len
sb.write_string('\t${bname}_len' + ' '.repeat(bn_diff_len - 4) + ' = $fbytes.len\n')
sb.write_string('\t${bname}_len' + ' '.repeat(bn_diff_len - 4) + ' = ${fbytes.len}\n')
fbyte := fbytes[0]
bnmae_line := '\t$bname' + ' '.repeat(bn_diff_len) + ' = [byte($fbyte), '
bnmae_line := '\t${bname}' + ' '.repeat(bn_diff_len) + ' = [u8(${fbyte}), '
sb.write_string(bnmae_line)
mut line_len := bnmae_line.len + 3
for i := 1; i < fbytes.len; i++ {
@@ -65,7 +65,7 @@ fn (context Context) file2v(bname string, fbytes []byte, bn_max int) string {
sb.write_string(b)
line_len += b.len
} else {
sb.write_string('$b, ')
sb.write_string('${b}, ')
line_len += b.len + 2
}
}
@@ -73,11 +73,11 @@ fn (context Context) file2v(bname string, fbytes []byte, bn_max int) string {
return sb.str()
}
fn (context Context) bname_and_bytes(file string) ?(string, []byte) {
fn (context Context) bname_and_bytes(file string) !(string, []u8) {
fname := os.file_name(file)
fname_escaped := fname.replace_each(['.', '_', '-', '_'])
byte_name := '$context.prefix$fname_escaped'.to_lower()
fbytes := os.read_bytes(file) or { return error('Error: $err.msg') }
byte_name := '${context.prefix}${fname_escaped}'.to_lower()
fbytes := os.read_bytes(file) or { return error('Error: ${err.msg()}') }
return byte_name, fbytes
}
@@ -108,7 +108,7 @@ fn main() {
exit(0)
}
files := fp.finalize() or {
eprintln('Error: $err.msg')
eprintln('Error: ${err.msg()}')
exit(1)
}
real_files := files.filter(it != 'bin2v')
@@ -120,22 +120,22 @@ fn main() {
if context.write_file != '' && os.file_ext(context.write_file) !in ['.vv', '.v'] {
context.write_file += '.v'
}
mut file_byte_map := map[string][]byte{}
mut file_byte_map := map[string][]u8{}
for file in real_files {
bname, fbytes := context.bname_and_bytes(file) or {
eprintln(err.msg)
eprintln(err.msg())
exit(1)
}
file_byte_map[bname] = fbytes
}
max_bname := context.max_bname_len(file_byte_map.keys())
if context.write_file.len > 0 {
mut out_file := os.create(context.write_file) ?
out_file.write_string(context.header()) ?
mut out_file := os.create(context.write_file)!
out_file.write_string(context.header())!
for bname, fbytes in file_byte_map {
out_file.write_string(context.file2v(bname, fbytes, max_bname)) ?
out_file.write_string(context.file2v(bname, fbytes, max_bname))!
}
out_file.write_string(context.footer()) ?
out_file.write_string(context.footer())!
} else {
print(context.header())
for bname, fbytes in file_byte_map {

View File

@@ -8,9 +8,9 @@ const vroot = @VMODROOT
fn get_vdoctor_output(is_verbose bool) string {
vexe := os.getenv('VEXE')
verbose_flag := if is_verbose { '-v' } else { '' }
result := os.execute('${os.quoted_path(vexe)} $verbose_flag doctor')
result := os.execute('${os.quoted_path(vexe)} ${verbose_flag} doctor')
if result.exit_code != 0 {
eprintln('unable to get `v doctor` output: $result.output')
eprintln('unable to get `v doctor` output: ${result.output}')
return ''
}
return result.output
@@ -23,21 +23,21 @@ fn get_v_build_output(is_verbose bool, is_yes bool, file_path string) string {
wd := os.getwd()
os.chdir(vroot) or {}
verbose_flag := if is_verbose { '-v' } else { '' }
vdbg_path := $if windows { '$vroot/vdbg.exe' } $else { '$vroot/vdbg' }
vdbg_compilation_cmd := '${os.quoted_path(vexe)} $verbose_flag -g -o ${os.quoted_path(vdbg_path)} cmd/v'
vdbg_path := $if windows { '${vroot}/vdbg.exe' } $else { '${vroot}/vdbg' }
vdbg_compilation_cmd := '${os.quoted_path(vexe)} ${verbose_flag} -g -o ${os.quoted_path(vdbg_path)} cmd/v'
vdbg_result := os.execute(vdbg_compilation_cmd)
os.chdir(wd) or {}
if vdbg_result.exit_code == 0 {
vexe = vdbg_path
} else {
eprintln('unable to compile V in debug mode: $vdbg_result.output\ncommand: $vdbg_compilation_cmd\n')
eprintln('unable to compile V in debug mode: ${vdbg_result.output}\ncommand: ${vdbg_compilation_cmd}\n')
}
//
mut result := os.execute('${os.quoted_path(vexe)} $verbose_flag ${os.quoted_path(file_path)}')
mut result := os.execute('${os.quoted_path(vexe)} ${verbose_flag} ${os.quoted_path(file_path)}')
defer {
os.rm(vdbg_path) or {
if is_verbose {
eprintln('unable to delete `vdbg`: $err')
eprintln('unable to delete `vdbg`: ${err}')
}
}
}
@@ -49,14 +49,14 @@ fn get_v_build_output(is_verbose bool, is_yes bool, file_path string) string {
}
os.rm(generated_file) or {
if is_verbose {
eprintln('unable to delete generated file: $err')
eprintln('unable to delete generated file: ${err}')
}
}
}
run := is_yes
|| ask('It looks like the compilation went well, do you want to run the file?')
if run {
result = os.execute('${os.quoted_path(vexe)} $verbose_flag run ${os.quoted_path(file_path)}')
result = os.execute('${os.quoted_path(vexe)} ${verbose_flag} run ${os.quoted_path(file_path)}')
if result.exit_code == 0 && !is_yes {
confirm_or_exit('It looks like the file ran correctly as well, are you sure you want to continue?')
}
@@ -66,7 +66,7 @@ fn get_v_build_output(is_verbose bool, is_yes bool, file_path string) string {
}
fn ask(msg string) bool {
prompt := os.input_opt('$msg [Y/n] ') or { 'y' }
prompt := os.input_opt('${msg} [Y/n] ') or { 'y' }
return prompt == '' || prompt[0].ascii_str().to_lower() != 'n'
}
@@ -90,7 +90,7 @@ fn main() {
}
else {
if !arg.ends_with('.v') && !arg.ends_with('.vsh') && !arg.ends_with('.vv') {
eprintln('unknown argument: `$arg`')
eprintln('unknown argument: `${arg}`')
exit(1)
}
if file_path != '' {
@@ -111,14 +111,14 @@ fn main() {
vdoctor_output := get_vdoctor_output(is_verbose)
// file content
file_content := os.read_file(file_path) or {
eprintln('unable to get file "$file_path" content: $err')
eprintln('unable to get file "${file_path}" content: ${err}')
''
}
// output from `v -g -o vdbg cmd/v && vdbg file.v`
build_output := get_v_build_output(is_verbose, is_yes, file_path)
// ask the user if he wants to submit even after an error
if !is_yes && (vdoctor_output == '' || file_content == '' || build_output == '') {
confirm_or_exit('An error occured retrieving the information, do you want to continue?')
confirm_or_exit('An error occurred retrieving the information, do you want to continue?')
}
expected_result := readline.read_line('What did you expect to see? ') or {
@@ -136,26 +136,26 @@ fn main() {
raw_body := '<!-- It is advisable to update all relevant modules using `v outdated` and `v install` -->
**V doctor:**
```
$vdoctor_output
${vdoctor_output}
```
**What did you do?**
`v -g -o vdbg cmd/v && vdbg $file_path`
`v -g -o vdbg cmd/v && vdbg ${file_path}`
{file_content}
**What did you expect to see?**
$expected_result
${expected_result}
**What did you see instead?**
```
$build_output```'
mut encoded_body := urllib.query_escape(raw_body.replace_once('{file_content}', '```v\n$file_content\n```'))
mut generated_uri := 'https://github.com/vlang/v/issues/new?labels=Bug&body=$encoded_body'
${build_output}```'
mut encoded_body := urllib.query_escape(raw_body.replace_once('{file_content}', '```v\n${file_content}\n```'))
mut generated_uri := 'https://github.com/vlang/v/issues/new?labels=Bug&body=${encoded_body}'
if generated_uri.len > 8192 {
// GitHub doesn't support URLs longer than 8192 characters
encoded_body = urllib.query_escape(raw_body.replace_once('{file_content}', 'See attached file `$file_path`'))
generated_uri = 'https://github.com/vlang/v/issues/new?labels=Bug&body=$encoded_body'
encoded_body = urllib.query_escape(raw_body.replace_once('{file_content}', 'See attached file `${file_path}`'))
generated_uri = 'https://github.com/vlang/v/issues/new?labels=Bug&body=${encoded_body}'
println('Your file is too big to be submitted. Head over to the following URL and attach your file.')
println(generated_uri)
} else {

View File

@@ -3,16 +3,23 @@ module main
import os
import testing
const vroot = @VMODROOT
const vroot = os.dir(os.real_path(os.getenv_opt('VEXE') or { @VEXE }))
// build as a project folder
const efolders = [
'examples/viewer',
'examples/vweb_orm_jwt',
'examples/vweb_fullstack',
]
pub fn normalised_vroot_path(path string) string {
return os.real_path(os.join_path_single(vroot, path)).replace('\\', '/')
}
fn main() {
args_string := os.args[1..].join(' ')
params := args_string.all_before('build-examples')
skip_prefixes := efolders.map(os.real_path(os.join_path_single(vroot, it)))
mut skip_prefixes := efolders.map(normalised_vroot_path(it))
res := testing.v_build_failing_skipped(params, 'examples', skip_prefixes, fn (mut session testing.TestSession) {
for x in efolders {
pathsegments := x.split_any('/')

View File

@@ -4,14 +4,14 @@ import os
import testing
import v.util
// NB: tools like vdoc are compiled in their own subfolder
// Note: tools like vdoc are compiled in their own subfolder
// => cmd/tools/vdoc/vdoc.exe
// Usually, they have several top level .v files in the subfolder,
// that cannot be compiled separately, but instead, the whole folder,
// should be compiled (v folder).
// To implement that, these folders are initially skipped, then added
// as a whole *after the testing.prepare_test_session call*.
const tools_in_subfolders = ['vdoc', 'vvet', 'vast']
const tools_in_subfolders = ['vdoc', 'vvet', 'vast', 'vwhere', 'vcreate']
// non_packaged_tools are tools that should not be packaged with
// prebuild versions of V, to keep the size smaller.
@@ -23,15 +23,15 @@ fn main() {
args_string := os.args[1..].join(' ')
vexe := os.getenv('VEXE')
vroot := os.dir(vexe)
os.chdir(vroot) ?
os.chdir(vroot)!
folder := os.join_path('cmd', 'tools')
tfolder := os.join_path(vroot, 'cmd', 'tools')
main_label := 'Building $folder ...'
finish_label := 'building $folder'
main_label := 'Building ${folder} ...'
finish_label := 'building ${folder}'
//
mut skips := []string{}
for stool in tools_in_subfolders {
skips << os.join_path(tfolder, stool)
skips << os.join_path(tfolder, stool).replace('\\', '/')
}
buildopts := args_string.all_before('build-tools')
mut session := testing.prepare_test_session(buildopts, folder, skips, main_label)
@@ -43,11 +43,11 @@ fn main() {
// eprintln('> session.skip_files: $session.skip_files')
session.test()
eprintln(session.benchmark.total_message(finish_label))
if session.failed {
if session.failed_cmds.len > 0 {
exit(1)
}
//
mut executables := os.ls(session.vtmp_dir) ?
mut executables := os.ls(session.vtmp_dir)!
executables.sort()
for texe in executables {
tname := texe.replace(os.file_ext(texe), '')
@@ -66,8 +66,9 @@ fn main() {
}
target_path := os.join_path(tfolder, texe)
os.mv_by_cp(tpath, target_path) or {
if !err.msg.contains('vbuild-tools') && !err.msg.contains('vtest-all') {
eprintln('error while moving $tpath to $target_path: $err.msg')
emsg := err.msg()
if !emsg.contains('vbuild-tools') && !emsg.contains('vtest-all') {
eprintln('error while moving ${tpath} to ${target_path}: ${emsg}')
}
continue
}

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Subhomoy Haldar. All rights reserved.
// Copyright (c) 2019-2023 Subhomoy Haldar. All rights reserved.
// Use of this source code is governed by an MIT license that can be found in the LICENSE file.
module main
@@ -20,7 +20,7 @@ const (
tool_version = \'1.2.1\'
version: \'0.2.42\'
VERSION = "1.23.8"
Examples:
Bump the patch version in v.mod if it exists
v bump --patch
@@ -68,7 +68,7 @@ fn get_replacement_function(options Options) ReplacementFunction {
}
fn process_file(input_file string, options Options) {
lines := os.read_lines(input_file) or { panic('Failed to read file: $input_file') }
lines := os.read_lines(input_file) or { panic('Failed to read file: ${input_file}') }
mut re := regex.regex_opt(semver_query) or { panic('Could not create a RegEx parser.') }
@@ -103,28 +103,28 @@ fn process_file(input_file string, options Options) {
os.rm(backup_file) or {}
// Rename the original to the backup.
os.mv(input_file, backup_file) or { panic('Failed to copy file: $input_file') }
os.mv(input_file, backup_file) or { panic('Failed to copy file: ${input_file}') }
// Process the old file and write it back to the original.
os.write_file(input_file, new_lines.join_lines()) or {
panic('Failed to write file: $input_file')
panic('Failed to write file: ${input_file}')
}
// Remove the backup file.
os.rm(backup_file) or {}
if replacement_complete {
println('Bumped version in $input_file')
println('Bumped version in ${input_file}')
} else {
println('No changes made in $input_file')
println('No changes made in ${input_file}')
}
}
fn main() {
if os.args.len < 2 {
println('Usage: $tool_name [options] [file1 file2 ...]
$tool_description
Try $tool_name -h for more help...')
println('Usage: ${tool_name} [options] [file1 file2 ...]
${tool_description}
Try ${tool_name} -h for more help...')
exit(1)
}
@@ -162,14 +162,14 @@ Try $tool_name -h for more help...')
for input_file in files {
if !os.exists(input_file) {
println('File not found: $input_file')
println('File not found: ${input_file}')
exit(1)
}
process_file(input_file, options)
}
}
fn validate_options(options Options) ? {
fn validate_options(options Options) ! {
if options.patch && options.major {
return error('Cannot specify both --patch and --major.')
}

View File

@@ -1,5 +1,17 @@
import os
const vexe = @VEXE
const tfolder = os.join_path(os.vtmp_dir(), 'v', 'vbump')
fn testsuite_begin() {
os.mkdir_all(tfolder) or {}
}
fn testsuite_end() {
os.rmdir_all(tfolder) or {}
}
struct BumpTestCase {
file_name string
contents string
@@ -61,28 +73,25 @@ fn main() {
},
]
fn run_individual_test(case BumpTestCase) ? {
vexe := @VEXE
temp_dir := os.temp_dir()
test_file := os.join_path_single(temp_dir, case.file_name)
fn run_individual_test(case BumpTestCase) ! {
test_file := os.join_path_single(tfolder, case.file_name)
os.rm(test_file) or {}
os.write_file(test_file, case.contents) ?
os.write_file(test_file, case.contents)!
//
os.execute_or_exit('${os.quoted_path(vexe)} bump --patch ${os.quoted_path(test_file)}')
patch_lines := os.read_lines(test_file) ?
patch_lines := os.read_lines(test_file)!
assert patch_lines[case.line] == case.expected_patch
os.execute_or_exit('${os.quoted_path(vexe)} bump --minor ${os.quoted_path(test_file)}')
minor_lines := os.read_lines(test_file) ?
minor_lines := os.read_lines(test_file)!
assert minor_lines[case.line] == case.expected_minor
os.execute_or_exit('${os.quoted_path(vexe)} bump --major ${os.quoted_path(test_file)}')
major_lines := os.read_lines(test_file) ?
major_lines := os.read_lines(test_file)!
assert major_lines[case.line] == case.expected_major
//
os.rm(test_file) ?
os.rm(test_file)!
}
fn test_all_bump_cases() {

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Alexander Medvednikov. All rights reserved.
// Copyright (c) 2019-2023 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module main
@@ -7,8 +7,7 @@ import os
import os.cmdline
import rand
import term
import vhelp
import v.pref
import v.help
import regex
const (
@@ -21,6 +20,10 @@ const (
hide_warnings = '-hide-warnings' in os.args || '-w' in os.args
show_progress = os.getenv('GITHUB_JOB') == '' && '-silent' !in os.args
non_option_args = cmdline.only_non_options(os.args[2..])
is_verbose = os.getenv('VERBOSE') != ''
vcheckfolder = os.join_path(os.vtmp_dir(), 'v', 'vcheck_${os.getuid()}')
should_autofix = os.getenv('VAUTOFIX') != ''
vexe = @VEXE
)
struct CheckResult {
@@ -40,13 +43,14 @@ fn (v1 CheckResult) + (v2 CheckResult) CheckResult {
fn main() {
if non_option_args.len == 0 || '-help' in os.args {
vhelp.show_topic('check-md')
help.print_and_exit('check-md')
exit(0)
}
if '-all' in os.args {
println('´-all´ flag is deprecated. Please use ´v check-md .´ instead.')
exit(1)
}
mut skip_line_length_check := '-skip-line-length-check' in os.args
if show_progress {
// this is intended to be replaced by the progress lines
println('')
@@ -56,6 +60,10 @@ fn main() {
if term_colors {
os.setenv('VCOLORS', 'always', true)
}
os.mkdir_all(vcheckfolder, mode: 0o700) or {} // keep directory private
defer {
os.rmdir_all(vcheckfolder) or {}
}
for i := 0; i < files_paths.len; i++ {
file_path := files_paths[i]
if os.is_dir(file_path) {
@@ -64,21 +72,22 @@ fn main() {
}
real_path := os.real_path(file_path)
lines := os.read_lines(real_path) or {
println('"$file_path" does not exist')
println('"${file_path}" does not exist')
res.warnings++
continue
}
mut mdfile := MDFile{
skip_line_length_check: skip_line_length_check
path: file_path
lines: lines
}
res += mdfile.check()
}
if res.errors == 0 && show_progress {
term.clear_previous_line()
clear_previous_line()
}
if res.warnings > 0 || res.errors > 0 || res.oks > 0 {
println('\nWarnings: $res.warnings | Errors: $res.errors | OKs: $res.oks')
println('\nWarnings: ${res.warnings} | Errors: ${res.errors} | OKs: ${res.oks}')
}
if res.errors > 0 {
exit(1)
@@ -89,7 +98,8 @@ fn md_file_paths(dir string) []string {
mut files_to_check := []string{}
md_files := os.walk_ext(dir, '.md')
for file in md_files {
if file.contains_any_substr(['/thirdparty/', 'CHANGELOG']) {
nfile := file.replace('\\', '/')
if nfile.contains_any_substr(['/thirdparty/', 'CHANGELOG']) {
continue
}
files_to_check << file
@@ -123,17 +133,15 @@ fn rtext(s string) string {
}
fn wline(file_path string, lnumber int, column int, message string) string {
return btext('$file_path:${lnumber + 1}:${column + 1}:') + btext(mtext(' warn:')) +
rtext(' $message')
return btext('${file_path}:${lnumber + 1}:${column + 1}:') + btext(mtext(' warn:')) +
rtext(' ${message}')
}
fn eline(file_path string, lnumber int, column int, message string) string {
return btext('$file_path:${lnumber + 1}:${column + 1}:') + btext(rtext(' error: $message'))
return btext('${file_path}:${lnumber + 1}:${column + 1}:') + btext(rtext(' error: ${message}'))
}
const (
default_command = 'compile'
)
const default_command = 'compile'
struct VCodeExample {
mut:
@@ -150,9 +158,10 @@ enum MDFileParserState {
}
struct MDFile {
path string
lines []string
path string
skip_line_length_check bool
mut:
lines []string
examples []VCodeExample
current VCodeExample
state MDFileParserState = .markdown
@@ -160,8 +169,8 @@ mut:
fn (mut f MDFile) progress(message string) {
if show_progress {
term.clear_previous_line()
println('File: ${f.path:-30s}, Lines: ${f.lines.len:5}, $message')
clear_previous_line()
println('File: ${f.path:-30s}, Lines: ${f.lines.len:5}, ${message}')
}
}
@@ -170,34 +179,36 @@ fn (mut f MDFile) check() CheckResult {
mut anchor_data := AnchorData{}
for j, line in f.lines {
// f.progress('line: $j')
if f.state == .vexample {
if line.len > too_long_line_length_example {
wprintln(wline(f.path, j, line.len, 'example lines must be less than $too_long_line_length_example characters'))
wprintln(line)
res.warnings++
if !f.skip_line_length_check {
if f.state == .vexample {
if line.len > too_long_line_length_example {
wprintln(wline(f.path, j, line.len, 'example lines must be less than ${too_long_line_length_example} characters'))
wprintln(line)
res.warnings++
}
} else if f.state == .codeblock {
if line.len > too_long_line_length_codeblock {
wprintln(wline(f.path, j, line.len, 'code lines must be less than ${too_long_line_length_codeblock} characters'))
wprintln(line)
res.warnings++
}
} else if line.starts_with('|') {
if line.len > too_long_line_length_table {
wprintln(wline(f.path, j, line.len, 'table lines must be less than ${too_long_line_length_table} characters'))
wprintln(line)
res.warnings++
}
} else if line.contains('http') {
if line.all_after('https').len > too_long_line_length_link {
wprintln(wline(f.path, j, line.len, 'link lines must be less than ${too_long_line_length_link} characters'))
wprintln(line)
res.warnings++
}
} else if line.len > too_long_line_length_other {
eprintln(eline(f.path, j, line.len, 'must be less than ${too_long_line_length_other} characters'))
eprintln(line)
res.errors++
}
} else if f.state == .codeblock {
if line.len > too_long_line_length_codeblock {
wprintln(wline(f.path, j, line.len, 'code lines must be less than $too_long_line_length_codeblock characters'))
wprintln(line)
res.warnings++
}
} else if line.starts_with('|') {
if line.len > too_long_line_length_table {
wprintln(wline(f.path, j, line.len, 'table lines must be less than $too_long_line_length_table characters'))
wprintln(line)
res.warnings++
}
} else if line.contains('http') {
if line.all_after('https').len > too_long_line_length_link {
wprintln(wline(f.path, j, line.len, 'link lines must be less than $too_long_line_length_link characters'))
wprintln(line)
res.warnings++
}
} else if line.len > too_long_line_length_other {
eprintln(eline(f.path, j, line.len, 'must be less than $too_long_line_length_other characters'))
eprintln(line)
res.errors++
}
if f.state == .markdown {
anchor_data.add_links(j, line)
@@ -219,7 +230,7 @@ fn (mut f MDFile) parse_line(lnumber int, line string) {
if command == '' {
command = default_command
} else if command == 'nofmt' {
command += ' $default_command'
command += ' ${default_command}'
}
f.current = VCodeExample{
sline: lnumber
@@ -326,14 +337,14 @@ fn (mut ad AnchorData) check_link_target_match(fpath string, mut res CheckResult
found_error_warning = true
res.errors++
for anchordata in ad.anchors[link] {
eprintln(eline(fpath, anchordata.line, 0, 'multiple link targets of existing link (#$link)'))
eprintln(eline(fpath, anchordata.line, 0, 'multiple link targets of existing link (#${link})'))
}
}
} else {
found_error_warning = true
res.errors++
for brokenlink in linkdata {
eprintln(eline(fpath, brokenlink.line, 0, 'no link target found for existing link [$brokenlink.lable](#$link)'))
eprintln(eline(fpath, brokenlink.line, 0, 'no link target found for existing link [${brokenlink.lable}](#${link})'))
}
}
}
@@ -349,7 +360,7 @@ fn (mut ad AnchorData) check_link_target_match(fpath string, mut res CheckResult
anchor.line
}
}
wprintln(wline(fpath, line, 0, 'multiple link target for non existing link (#$link)'))
wprintln(wline(fpath, line, 0, 'multiple link target for non existing link (#${link})'))
found_error_warning = true
res.warnings++
}
@@ -389,11 +400,12 @@ fn create_ref_link(s string) string {
fn (mut f MDFile) debug() {
for e in f.examples {
eprintln('f.path: $f.path | example: $e')
eprintln('f.path: ${f.path} | example: ${e}')
}
}
fn cmdexecute(cmd string) int {
verbose_println(cmd)
res := os.execute(cmd)
if res.exit_code < 0 {
return 1
@@ -405,6 +417,7 @@ fn cmdexecute(cmd string) int {
}
fn silent_cmdexecute(cmd string) int {
verbose_println(cmd)
res := os.execute(cmd)
return res.exit_code
}
@@ -416,8 +429,7 @@ fn get_fmt_exit_code(vfile string, vexe string) int {
fn (mut f MDFile) check_examples() CheckResult {
mut errors := 0
mut oks := 0
vexe := pref.vexe_path()
for e in f.examples {
recheck_all_examples: for e in f.examples {
if e.command == 'ignore' {
continue
}
@@ -426,7 +438,9 @@ fn (mut f MDFile) check_examples() CheckResult {
}
fname := os.base(f.path).replace('.md', '_md')
uid := rand.ulid()
vfile := os.join_path(os.temp_dir(), 'check_${fname}_example_${e.sline}__${e.eline}__${uid}.v')
cfile := os.join_path(vcheckfolder, '${uid}.c')
vfile := os.join_path(vcheckfolder, 'check_${fname}_example_${e.sline}__${e.eline}__${uid}.v')
efile := os.join_path(vcheckfolder, 'check_${fname}_example_${e.sline}__${e.eline}__${uid}.exe')
mut should_cleanup_vfile := true
// eprintln('>>> checking example $vfile ...')
vcontent := e.text.join('\n') + '\n'
@@ -434,18 +448,37 @@ fn (mut f MDFile) check_examples() CheckResult {
mut acommands := e.command.split(' ')
nofmt := 'nofmt' in acommands
for command in acommands {
f.progress('example from $e.sline to $e.eline, command: $command')
f.progress('example from ${e.sline} to ${e.eline}, command: ${command}')
fmt_res := if nofmt { 0 } else { get_fmt_exit_code(vfile, vexe) }
match command {
'compile' {
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -o x.c ${os.quoted_path(vfile)}')
os.rm('x.c') or {}
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -o ${os.quoted_path(efile)} ${os.quoted_path(vfile)}')
if res != 0 || fmt_res != 0 {
if res != 0 {
eprintln(eline(f.path, e.sline, 0, 'example failed to compile'))
}
if fmt_res != 0 {
eprintln(eline(f.path, e.sline, 0, 'example is not formatted'))
f.report_not_formatted_example_if_needed(e, fmt_res, vfile) or {
unsafe {
goto recheck_all_examples
}
}
eprintln(vcontent)
should_cleanup_vfile = false
errors++
continue
}
oks++
}
'cgen' {
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -o ${os.quoted_path(cfile)} ${os.quoted_path(vfile)}')
if res != 0 || fmt_res != 0 {
if res != 0 {
eprintln(eline(f.path, e.sline, 0, 'example failed to generate C code'))
}
f.report_not_formatted_example_if_needed(e, fmt_res, vfile) or {
unsafe {
goto recheck_all_examples
}
}
eprintln(vcontent)
should_cleanup_vfile = false
@@ -455,14 +488,15 @@ fn (mut f MDFile) check_examples() CheckResult {
oks++
}
'globals' {
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -enable-globals -o x.c ${os.quoted_path(vfile)}')
os.rm('x.c') or {}
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -enable-globals -o ${os.quoted_path(cfile)} ${os.quoted_path(vfile)}')
if res != 0 || fmt_res != 0 {
if res != 0 {
eprintln(eline(f.path, e.sline, 0, '`example failed to compile with -enable-globals'))
}
if fmt_res != 0 {
eprintln(eline(f.path, e.sline, 0, '`example is not formatted'))
f.report_not_formatted_example_if_needed(e, fmt_res, vfile) or {
unsafe {
goto recheck_all_examples
}
}
eprintln(vcontent)
should_cleanup_vfile = false
@@ -472,13 +506,33 @@ fn (mut f MDFile) check_examples() CheckResult {
oks++
}
'live' {
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -live -o x.c ${os.quoted_path(vfile)}')
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -live -o ${os.quoted_path(cfile)} ${os.quoted_path(vfile)}')
if res != 0 || fmt_res != 0 {
if res != 0 {
eprintln(eline(f.path, e.sline, 0, 'example failed to compile with -live'))
}
if fmt_res != 0 {
eprintln(eline(f.path, e.sline, 0, 'example is not formatted'))
f.report_not_formatted_example_if_needed(e, fmt_res, vfile) or {
unsafe {
goto recheck_all_examples
}
}
eprintln(vcontent)
should_cleanup_vfile = false
errors++
continue
}
oks++
}
'shared' {
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -shared -o ${os.quoted_path(cfile)} ${os.quoted_path(vfile)}')
if res != 0 || fmt_res != 0 {
if res != 0 {
eprintln(eline(f.path, e.sline, 0, 'module example failed to compile with -shared'))
}
f.report_not_formatted_example_if_needed(e, fmt_res, vfile) or {
unsafe {
goto recheck_all_examples
}
}
eprintln(vcontent)
should_cleanup_vfile = false
@@ -488,14 +542,15 @@ fn (mut f MDFile) check_examples() CheckResult {
oks++
}
'failcompile' {
res := silent_cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -o x.c ${os.quoted_path(vfile)}')
os.rm('x.c') or {}
res := silent_cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -o ${os.quoted_path(cfile)} ${os.quoted_path(vfile)}')
if res == 0 || fmt_res != 0 {
if res == 0 {
eprintln(eline(f.path, e.sline, 0, '`failcompile` example compiled'))
}
if fmt_res != 0 {
eprintln(eline(f.path, e.sline, 0, 'example is not formatted'))
f.report_not_formatted_example_if_needed(e, fmt_res, vfile) or {
unsafe {
goto recheck_all_examples
}
}
eprintln(vcontent)
should_cleanup_vfile = false
@@ -510,8 +565,24 @@ fn (mut f MDFile) check_examples() CheckResult {
if res != 0 {
eprintln(eline(f.path, e.sline, 0, '`oksyntax` example with invalid syntax'))
}
if fmt_res != 0 {
eprintln(eline(f.path, e.sline, 0, '`oksyntax` example is not formatted'))
f.report_not_formatted_example_if_needed(e, fmt_res, vfile) or {
unsafe {
goto recheck_all_examples
}
}
eprintln(vcontent)
should_cleanup_vfile = false
errors++
continue
}
oks++
}
'okfmt' {
if fmt_res != 0 {
f.report_not_formatted_example_if_needed(e, fmt_res, vfile) or {
unsafe {
goto recheck_all_examples
}
}
eprintln(vcontent)
should_cleanup_vfile = false
@@ -532,13 +603,21 @@ fn (mut f MDFile) check_examples() CheckResult {
oks++
}
'nofmt' {}
// mark the example as playable inside docs
'play' {}
// same as play, but run example as a test
'play-test' {}
// when ```vmod
'mod' {}
else {
eprintln(eline(f.path, e.sline, 0, 'unrecognized command: "$command", use one of: wip/ignore/compile/failcompile/oksyntax/badsyntax'))
eprintln(eline(f.path, e.sline, 0, 'unrecognized command: "${command}", use one of: wip/ignore/compile/failcompile/okfmt/nofmt/oksyntax/badsyntax/cgen/globals/live/shared'))
should_cleanup_vfile = false
errors++
}
}
}
os.rm(cfile) or {}
os.rm(efile) or {}
if should_cleanup_vfile {
os.rm(vfile) or { panic(err) }
}
@@ -548,3 +627,65 @@ fn (mut f MDFile) check_examples() CheckResult {
oks: oks
}
}
fn verbose_println(message string) {
if is_verbose {
println(message)
}
}
fn clear_previous_line() {
if is_verbose {
return
}
term.clear_previous_line()
}
fn (mut f MDFile) report_not_formatted_example_if_needed(e VCodeExample, fmt_res int, vfile string) ! {
if fmt_res == 0 {
return
}
eprintln(eline(f.path, e.sline, 0, 'example is not formatted'))
if !should_autofix {
return
}
f.autofix_example(e, vfile) or {
if err is ExampleWasRewritten {
eprintln('>> f.path: ${f.path} | example from ${e.sline} to ${e.eline} was re-formated by vfmt')
return err
}
eprintln('>> f.path: ${f.path} | encountered error while autofixing the example: ${err}')
}
}
struct ExampleWasRewritten {
Error
}
fn (mut f MDFile) autofix_example(e VCodeExample, vfile string) ! {
eprintln('>>> AUTOFIXING f.path: ${f.path} | e.sline: ${e.sline} | vfile: ${vfile}')
res := cmdexecute('${os.quoted_path(vexe)} fmt -w ${os.quoted_path(vfile)}')
if res != 0 {
return error('could not autoformat the example')
}
formatted_content_lines := os.read_lines(vfile) or { return }
mut new_lines := []string{}
new_lines << f.lines#[0..e.sline + 1]
new_lines << formatted_content_lines
new_lines << f.lines#[e.eline..]
f.update_examples(new_lines)!
os.rm(vfile) or {}
f.examples = f.examples.filter(it.sline >= e.sline)
return ExampleWasRewritten{}
}
fn (mut f MDFile) update_examples(new_lines []string) ! {
os.write_file(f.path, new_lines.join('\n'))!
f.lines = new_lines
f.examples = []
f.current = VCodeExample{}
f.state = .markdown
for j, line in f.lines {
f.parse_line(j, line)
}
}

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2019-2022 Alexander Medvednikov. All rights reserved.
// Copyright (c) 2019-2023 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
//
@@ -76,7 +76,7 @@ SUBCMD:
// Snooped from cmd/v/v.v, vlib/v/pref/pref.v
const (
auto_complete_commands = [
auto_complete_commands = [
// simple_cmd
'ast',
'doc',
@@ -95,6 +95,7 @@ const (
'doctor',
'fmt',
'gret',
'ls',
'repl',
'self',
'setup-freetype',
@@ -114,7 +115,6 @@ const (
'help',
'new',
'init',
'complete',
'translate',
'self',
'search',
@@ -130,8 +130,13 @@ const (
'run',
'build',
'build-module',
'missdoc',
]
auto_complete_flags = [
// Entries in the flag arrays below should be entered as is:
// * Short flags, e.g.: "-v", should be entered: '-v'
// * Long flags, e.g.: "--version", should be entered: '--version'
// * Single-dash flags, e.g.: "-version", should be entered: '-version'
auto_complete_flags = [
'-apk',
'-show-timings',
'-check-syntax',
@@ -150,6 +155,7 @@ const (
'-autofree',
'-compress',
'-freestanding',
'-no-parallel',
'-no-preludes',
'-prof',
'-profile',
@@ -190,7 +196,7 @@ const (
'-version',
'--version',
]
auto_complete_flags_doc = [
auto_complete_flags_doc = [
'-all',
'-f',
'-h',
@@ -203,12 +209,13 @@ const (
'-pos',
'-no-timestamp',
'-inline-assets',
'-theme-dir',
'-open',
'-p',
'-s',
'-l',
]
auto_complete_flags_fmt = [
auto_complete_flags_fmt = [
'-c',
'-diff',
'-l',
@@ -216,7 +223,7 @@ const (
'-debug',
'-verify',
]
auto_complete_flags_bin2v = [
auto_complete_flags_bin2v = [
'-h',
'--help',
'-m',
@@ -226,22 +233,46 @@ const (
'-w',
'--write',
]
auto_complete_flags_shader = [
'help',
'h',
'force-update',
'u',
'verbose',
'v',
'slang',
'l',
'output',
'o',
auto_complete_flags_shader = [
'--help',
'-h',
'--force-update',
'-u',
'--verbose',
'-v',
'--slang',
'-l',
'--output',
'-o',
]
auto_complete_flags_self = [
auto_complete_flags_missdoc = [
'--help',
'-h',
'--tags',
'-t',
'--deprecated',
'-d',
'--private',
'-p',
'--no-line-numbers',
'-n',
'--exclude',
'-e',
'--relative-paths',
'-r',
'--js',
'--verify',
'--diff',
]
auto_complete_flags_bump = [
'--patch',
'--minor',
'--major',
]
auto_complete_flags_self = [
'-prod',
]
auto_complete_compilers = [
auto_complete_compilers = [
'cc',
'gcc',
'tcc',
@@ -264,12 +295,12 @@ fn auto_complete(args []string) {
println(setup_for_shell(shell_name))
exit(0)
}
eprintln('Unknown shell ${shell_name}. Supported shells are: $auto_complete_shells')
eprintln('Unknown shell ${shell_name}. Supported shells are: ${auto_complete_shells}')
exit(1)
}
eprintln('auto completion require arguments to work.')
} else {
eprintln('auto completion failed for "$args".')
eprintln('auto completion failed for "${args}".')
}
exit(1)
}
@@ -278,7 +309,7 @@ fn auto_complete(args []string) {
match sub {
'setup' {
if sub_args.len <= 1 || sub_args[1] !in auto_complete_shells {
eprintln('please specify a shell to setup auto completion for ($auto_complete_shells).')
eprintln('please specify a shell to setup auto completion for (${auto_complete_shells}).')
exit(1)
}
shell := sub_args[1]
@@ -291,7 +322,7 @@ fn auto_complete(args []string) {
mut lines := []string{}
list := auto_complete_request(sub_args[1..])
for entry in list {
lines << "COMPREPLY+=('$entry')"
lines << "COMPREPLY+=('${entry}')"
}
println(lines.join('\n'))
}
@@ -302,7 +333,7 @@ fn auto_complete(args []string) {
mut lines := []string{}
list := auto_complete_request(sub_args[1..])
for entry in list {
lines << '$entry'
lines << '${entry}'
}
println(lines.join('\n'))
}
@@ -313,7 +344,7 @@ fn auto_complete(args []string) {
mut lines := []string{}
list := auto_complete_request(sub_args[1..])
for entry in list {
lines << 'compadd -U -S' + '""' + ' -- ' + "'$entry';"
lines << 'compadd -U -S' + '""' + ' -- ' + "'${entry}';"
}
println(lines.join('\n'))
}
@@ -325,8 +356,8 @@ fn auto_complete(args []string) {
exit(0)
}
// append_separator_if_dir is a utility function.that returns the input `path` appended an
// OS dependant path separator if the `path` is a directory.
// append_separator_if_dir returns the input `path` with an appended
// `/` or `\`, depending on the platform, when `path` is a directory.
fn append_separator_if_dir(path string) string {
if os.is_dir(path) && !path.ends_with(os.path_separator) {
return path + os.path_separator
@@ -347,7 +378,7 @@ fn nearest_path_or_root(path string) string {
return fixed_path
}
// auto_complete_request retuns a list of completions resolved from a full argument list.
// auto_complete_request returns a list of completions resolved from a full argument list.
fn auto_complete_request(args []string) []string {
// Using space will ensure a uniform input in cases where the shell
// returns the completion input as a string (['v','run'] vs. ['v run']).
@@ -371,12 +402,17 @@ fn auto_complete_request(args []string) []string {
parent_command = parts[i]
break
}
get_flags := fn (base []string, flag string) []string {
if flag.len == 1 { return base
} else { return base.filter(it.starts_with(flag))
}
}
if part.starts_with('-') { // 'v -<tab>' -> flags.
if part.starts_with('-') { // 'v [subcmd] -<tab>' or 'v [subcmd] --<tab>'-> flags.
get_flags := fn (base []string, flag string) []string {
mut results := []string{}
for entry in base {
if entry.starts_with(flag) {
results << entry
}
}
return results
}
match parent_command {
'bin2v' { // 'v bin2v -<tab>'
list = get_flags(auto_complete_flags_bin2v, part)
@@ -396,6 +432,12 @@ fn auto_complete_request(args []string) []string {
'shader' { // 'v shader -<tab>' -> flags.
list = get_flags(auto_complete_flags_shader, part)
}
'missdoc' { // 'v missdoc -<tab>' -> flags.
list = get_flags(auto_complete_flags_missdoc, part)
}
'bump' { // 'v bump -<tab>' -> flags.
list = get_flags(auto_complete_flags_bump, part)
}
else {
for flag in auto_complete_flags {
if flag == part {
@@ -413,6 +455,11 @@ fn auto_complete_request(args []string) []string {
}
}
}
// Clear the list if the result is identical to the part examined
// (the flag must have already been completed)
if list.len == 1 && part == list[0] {
list.clear()
}
} else {
match part {
'help' { // 'v help <tab>' -> top level commands except "help".
@@ -471,6 +518,17 @@ fn auto_complete_request(args []string) []string {
}
}
} else {
// Handle special case, where there is only one file in the directory
// being completed - if it can be resolved we return that since
// handling it in the generalized logic below will result in
// more complexity.
if entries.len == 1 && os.is_file(os.join_path(ls_path, entries[0])) {
mut keep_input_path_format := ls_path
if !part.starts_with('./') && ls_path.starts_with('./') {
keep_input_path_format = keep_input_path_format.all_after('./')
}
return [os.join_path(keep_input_path_format, entries[0])]
}
for entry in entries {
if collect_all || entry.starts_with(last) {
list << append_separator_if_dir(entry)
@@ -495,7 +553,7 @@ _v_completions() {
local limit
# Send all words up to the word the cursor is currently on
let limit=1+\$COMP_CWORD
src=\$($vexe complete bash \$(printf "%s\\n" \${COMP_WORDS[@]: 0:\$limit}))
src=\$(${vexe} complete bash \$(printf "%s\\n" \${COMP_WORDS[@]: 0:\$limit}))
if [[ \$? == 0 ]]; then
eval \${src}
#echo \${src}
@@ -509,7 +567,7 @@ complete -o nospace -F _v_completions v
setup = '
function __v_completions
# Send all words up to the one before the cursor
$vexe complete fish (commandline -cop)
${vexe} complete fish (commandline -cop)
end
complete -f -c v -a "(__v_completions)"
'
@@ -520,7 +578,7 @@ complete -f -c v -a "(__v_completions)"
_v() {
local src
# Send all words up to the word the cursor is currently on
src=\$($vexe complete zsh \$(printf "%s\\n" \${(@)words[1,\$CURRENT]}))
src=\$(${vexe} complete zsh \$(printf "%s\\n" \${(@)words[1,\$CURRENT]}))
if [[ \$? == 0 ]]; then
eval \${src}
#echo \${src}
@@ -533,7 +591,7 @@ compdef _v v
setup = '
Register-ArgumentCompleter -Native -CommandName v -ScriptBlock {
param(\$commandName, \$wordToComplete, \$cursorPosition)
$vexe complete powershell "\$wordToComplete" | ForEach-Object {
${vexe} complete powershell "\$wordToComplete" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(\$_, \$_, \'ParameterValue\', \$_)
}
}

Some files were not shown because too many files have changed in this diff Show More