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

11545 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
谢克
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
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
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
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
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
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
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
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
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
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
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
shove
5ef4e0c9be
cgen: fix "fn()?.field?" expr cgen error (fix #16482) (#16488) 2022-11-19 20:30:24 +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
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
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
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
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
Junko
5bb058e35b
gg: revamp the Context pipeline for more effects, implement an additive effect (#16394) 2022-11-12 09:39:18 +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
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
pancake
407bb6641f
cgen: fix #16326 -cstrict with $embed_file (#16343) 2022-11-06 15:47:06 +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
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
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
yuyi
a979b3aab8
scanner: fix new string interpolation - print('{a}{{b}}') (#16309) 2022-11-03 14:04:41 +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
shove
dddcf423db
all: replace x[x.len-1] with x.last() (#16296) 2022-11-02 21:08:33 +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