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

1526 Commits

Author SHA1 Message Date
Alexander Medvednikov
5b15b8ccc9 checker: do not allow casting strings 2020-05-16 22:52:41 +02:00
Alexander Medvednikov
6e4ae5a5e6 checker: do not allow casting strings 2020-05-16 22:48:45 +02:00
Alexander Medvednikov
0845b2cfbe builder: skip warnings; pref: move pref creation to pref.v 2020-05-16 22:45:38 +02:00
Delyan Angelov
62cb48d252 repl: treat middle imports in a more forgiving way 2020-05-16 22:03:28 +03:00
yuyi
6855996cca
cgen: fix array_init_with_default 2020-05-16 19:05:26 +02:00
yuyi
655d9bda94
cgen: remove extra ; from if_expr 2020-05-16 17:09:57 +02:00
Enzo Baldisserri
f44a40eee0
checker: check incorrect names 2020-05-16 16:12:23 +02:00
Swastik Baranwal
37cf46d67a
checker: add more checks for modulo 2020-05-16 15:32:46 +02:00
yuyi
9b6ee8e77d
cgen: array_init_with_default 2020-05-16 15:21:37 +02:00
Delyan Angelov
789b75df92 cheaders: fix _MOV macro in the C case 2020-05-16 15:51:09 +03:00
Larpon
aa30549337
scanner: fill out '@FN' placeholder at compile time while scanning 2020-05-16 14:20:19 +02:00
Tanel Liiv
44502a3fb2
parser: return multi expr 2020-05-15 23:14:53 +02:00
Alexander Medvednikov
7caebc5781 doc: print available modules 2020-05-15 23:09:38 +02:00
spaceface777
7c9bb44784 parser: allow JS methods with more than 1 dot 2020-05-15 22:26:51 +02:00
Delyan Angelov
5d0cc0944e parser: fix v_panic due to -pos in unused var warning (with tcc) 2020-05-15 20:11:27 +03:00
Alexander Medvednikov
c4ca6a9113 sokol: make examples compile 2020-05-15 18:55:29 +02:00
spaceface777
8de6da01d6
jsgen: prefix JS keywords with 'v_' 2020-05-15 15:55:49 +02:00
yuyi
8500c8885c
cgen: fix optional_void error; handle ? return type 2020-05-15 15:55:03 +02:00
Delyan Angelov
66cb61c242 builtin: cleanup by turning backtrace* fns to ordinary C. fns 2020-05-15 15:52:06 +03:00
Delyan Angelov
e18268e2f4 cheaders: use backtrace* stubs for both android & musl 2020-05-15 15:37:59 +03:00
Delyan Angelov
2c93deb884 builtin: bootstrap for backtrace functions cleanup 2020-05-15 15:08:42 +03:00
Enzo Baldisserri
d60233b618
cgen: simplify for in range 2020-05-14 22:22:32 +02:00
Alexander Medvednikov
0f251e9ede checker: handle json.decode correctly 2020-05-14 18:30:30 +02:00
Alexander Medvednikov
f49ef39708 checker: handle unexpected or blocks 2020-05-14 18:19:40 +02:00
Alexander Medvednikov
e5d4786371 builder: simplify C error message 2020-05-14 18:14:38 +02:00
Enzo Baldisserri
fd0d833e33
gen: if expressions with multiple statements 2020-05-14 17:15:25 +02:00
wilesun
2a9cbbe157
cgen: handle sizeof(C.struct) 2020-05-14 17:14:59 +02:00
yuyi
6d0b791ac8
parser: warning about unused imports 2020-05-14 17:14:24 +02:00
Alexander Medvednikov
2369a5c8c6 cgen: handle is for interfaces 2020-05-14 16:56:45 +02:00
yuyi
70b76a8e31
builder: use verror for not found modules 2020-05-14 10:59:29 +03:00
Delyan Angelov
74005b4362 vfmt: handle file paths with spaces 2020-05-14 09:07:14 +03:00
Delyan Angelov
d830620651 compiler: restore support for --enable-globals flag, and add tests. 2020-05-14 08:43:12 +03:00
Alexander Medvednikov
1cb4aa7642 builder: cross compiling for linux, part 1 2020-05-14 04:15:04 +02:00
Alexander Medvednikov
e60e8f3b34 builder: bring back cross compilation for windows 2020-05-13 23:02:31 +02:00
Alexander Medvednikov
1bf26a35fa array: rename default to init 2020-05-13 22:00:24 +02:00
Alexander Medvednikov
ab7bc760c6 cgen: new Option part 1 2020-05-13 21:59:08 +02:00
Sandro Martini
9895cab51c
tests: add more tests on interfaces 2020-05-13 20:30:18 +02:00
Enzo Baldisserri
1ca04e6113
checker: prevent interface instantiation 2020-05-13 19:20:15 +02:00
yuyi
2e0b9de31c
parser: error for consts in fns 2020-05-13 18:39:02 +02:00
Enzo Baldisserri
172e4ff853
cgen: simplify if guard else clause 2020-05-13 18:38:00 +02:00
Alexander Medvednikov
33a9822548 parser/vfmt: handle array len and default in array init 2020-05-13 16:11:52 +02:00
Alexander Medvednikov
db5036686b checker: make type is private warning an errror 2020-05-13 14:21:52 +02:00
yuyi
b1511ce995
parser: optimize no main file process 2020-05-13 14:02:04 +02:00
Tanel Liiv
af334e320c
cgen: dereference in one place and fix 2020-05-13 01:01:34 +02:00
Alexander Medvednikov
3e6f7d3eb6 freetype: minor fixes 2020-05-13 00:50:46 +02:00
Alexander Medvednikov
7a5a4df4c6 checker: handle println() 2020-05-12 19:38:46 +02:00
yuyi
7837abf6b0
parser: optimize stmt() 2020-05-12 17:18:25 +02:00
yuyi
99b31d8241
parser: unified way to handle struct and enum name check 2020-05-12 13:39:32 +02:00
Alexander Medvednikov
712fd384ee parser: fix eval not used in match 2020-05-12 00:26:39 +02:00
Alexander Medvednikov
27d3800cc3 parser: bring back "evaluated but not used" 2020-05-12 00:19:45 +02:00
Alexander Medvednikov
1c8e14c77c vfmt: handle comments in const blocks 2020-05-12 00:09:59 +02:00
yuyi
dea2658a80
checker: minor optimization in infix_expr 2020-05-11 23:50:13 +02:00
Kris Cherven
d359a7aefb
cgen: fix a goto error 2020-05-11 23:49:08 +02:00
JalonSolov
649a0140fd
x64: fix NUL at end of strings, and length 2020-05-11 16:50:36 +02:00
Alexander Medvednikov
e9177faf17 checker: allow *x = y only inside unsafe blocks 2020-05-11 16:05:59 +02:00
Alexander Medvednikov
2618b4fbd3 Revert "tests: add more tests on interfaces "
This reverts commit 538662d99a.
2020-05-11 15:19:55 +02:00
Alexander Medvednikov
aacc35db19 pref: do not enable globals by default 2020-05-11 15:19:47 +02:00
Sandro Martini
538662d99a
tests: add more tests on interfaces 2020-05-11 15:13:03 +02:00
kdmult
ea8fcb3981
cgen: fix nested conditional statements 2020-05-11 15:11:48 +02:00
Alexey
6f2dcd819f
parser: force visibility of interface methods 2020-05-11 15:10:26 +02:00
Alexander Medvednikov
828f9af64c checker: fmt 2020-05-11 14:38:25 +02:00
Alexander Medvednikov
8a6820d1b7 checker: revert fmt for now 2020-05-11 14:32:41 +02:00
Alexander Medvednikov
ce03761375 parser: fix mut args with the new syntax; checker: fmt 2020-05-11 14:16:20 +02:00
joe-conigliaro
2a40665919
ast/checker: cast no longer needed & use auto deref 2020-05-11 20:02:28 +10:00
Kris Cherven
8bc0c31f29
parser: add error for variables, that are evaluated, but not used 2020-05-11 11:13:36 +03:00
Kris Cherven
3a3d00ac72
checker: prevent C error on const mutation 2020-05-11 11:09:58 +03:00
Ned Palacios
38277d1dac
cgen: fix gen_str_for_struc when called on a struct with a pointer field 2020-05-11 11:08:21 +03:00
joe-conigliaro
1b3cd7abe0
cgen: fix sum type assign/push from in match branch & type mod 2020-05-11 16:59:55 +10:00
yuyi
64ba59590e
cgen: fix multiple assign error 2020-05-11 09:45:11 +03:00
joe-conigliaro
74cc2b2a68
table: add function return type check 2020-05-11 14:47:39 +10:00
yuyi
14bba54ddc
vrepl: fix array_init error
* optimize print conditions
2020-05-11 07:15:08 +03:00
Alexey
71c2b26103
checker: fix checking uninitialized refs 2020-05-10 22:26:47 +02:00
Enzo Baldisserri
b09fd66aa2
gen: fix interface pointers 2020-05-10 21:16:22 +02:00
Delyan Angelov
1bf13f8a09 v version: do more accurate current git hash detection, when not on a branch 2020-05-10 18:56:19 +03:00
Alexander Medvednikov
a2d120b583 cgen: fix reassignment of optionals 2020-05-10 17:41:33 +02:00
eyelash
1722171adc
compiler: color only the relevant part of the source code in error messages 2020-05-10 17:24:29 +02:00
eyelash
72dfe11fa5
scanner: add a colon to error messages (#4818) 2020-05-10 16:29:15 +02:00
eyelash
f396f70ae7
repl: fix newline in error messages 2020-05-10 16:26:56 +02:00
Sumeet Chhetri
8dc0c5a699
cgen: C++ compiler support - Part 1 2020-05-10 16:26:21 +02:00
joe-conigliaro
a73660a4c3
checker/cgen: simplify assigning fn to var 2020-05-11 00:13:30 +10:00
eyelash
eabc72d4fe
compiler: print underlines in the same color as the error 2020-05-10 12:27:46 +02:00
Ned Palacios
5f0ad0f562
compiler: add output mode for errors and warnings, support for -silent flag 2020-05-10 12:26:57 +03:00
Ned Palacios
01de1b6375
parser: fix JSON encode function name on invocation 2020-05-10 10:30:35 +03:00
yuyi
7f69c2fbf5
parser: check import in the middle of file error 2020-05-10 07:47:20 +03:00
yuyi
ba3a631954
parser: check for module statement errors 2020-05-10 02:28:56 +02:00
yuyi
85723e3799
checker: check for_in_map using one variable error 2020-05-10 02:28:43 +02:00
Alexander Medvednikov
10da871743 checker: handle unknown fields in fail_if_immutable 2020-05-10 02:07:15 +02:00
Alexander Medvednikov
09f6cd6a75 parser/checker: [ref_only] attribute 2020-05-09 23:45:41 +02:00
Alexander Medvednikov
3052266a40 live: make compile; pref: allow _linux.v etc 2020-05-09 20:31:50 +02:00
Alexander Medvednikov
d7c4630d33 checker: make pub field check an error 2020-05-09 18:34:07 +02:00
yuyi
3eeef6203e
checker: check for map_init key duplicate 2020-05-09 16:55:38 +02:00
Alexander Medvednikov
dea9ca2491 cgen: fix a big with &Foo{} init 2020-05-09 15:23:48 +02:00
Alexander Medvednikov
c64f8b0d1f parser/checker: pub: struct fields 2020-05-09 15:16:48 +02:00
Delyan Angelov
809676a856 cgen: fix a sporadic segfault when giving -width in a string interpolation 2020-05-09 15:23:37 +03:00
yuyi
5f435fa1cc
parser: check enum name and field name errors 2020-05-09 12:43:10 +02:00
Tanel Liiv
7815a5495c
checker: handle multireturn fn calls as if/match last expressions 2020-05-08 22:49:45 +02:00
Sandro Martini
910a8934cb
checker: fix typo on error message and related test 2020-05-08 21:21:47 +03:00
Alexander Medvednikov
6ea741e26e Revert "tests: valgrind: enable string tests"
This reverts commit 1ea13ac7f3.
2020-05-08 16:18:14 +02:00
Alexander Medvednikov
1ea13ac7f3 tests: valgrind: enable string tests 2020-05-08 13:18:27 +00:00
Ned Palacios
5b47ec49af
parser: add support for multiple struct field attributes 2020-05-08 15:09:42 +02:00
Alexander Medvednikov
c29f76454e cgen: clone strings in struct_init() 2020-05-08 15:07:53 +02:00
yuyi
ef505e21ee
parser: check for import errors 2020-05-08 16:01:54 +03:00
Alexander Medvednikov
2f4fc86d58 checker: fix unknown var enum crash 2020-05-08 15:00:06 +02:00
Delyan Angelov
e08566d571 compiler: do not exit early, when given -o x.c or -o x.js 2020-05-08 15:31:03 +03:00
Delyan Angelov
4c320e1512 profile: support for -profile-no-inline (with it, [inline] fns will not get profiled) 2020-05-08 15:01:59 +03:00
Alexander Medvednikov
847a1035a5 cgen: use tos_lit 2020-05-08 13:25:23 +02:00
Ned Palacios
13b11a4155
parser: fix struct attribute for array struct field 2020-05-08 13:09:40 +02:00
Delyan Angelov
fec7f0f0b9 cgen: fix auto .str() generation for []&T, and fn (t &T) str() string{} 2020-05-08 12:48:07 +03:00
yuyi
8866773f97
vrepl: fix import and comment error in the middle of other lines 2020-05-08 09:34:59 +03:00
Delyan Angelov
673acdbd00 tcc: fix selfcompilation with tcc. Temporarily disable crashing interface test 2020-05-07 20:59:45 +03:00
Delyan Angelov
7207a4970b solaris: fix tests 2020-05-07 16:19:21 +00:00
Alexander Medvednikov
8cfb2ad6c9 string: is_lit 2020-05-07 18:05:57 +02:00
Alexander Medvednikov
ef387779bf cgen: fix -autofree 2020-05-07 17:51:30 +02:00
Alexander Medvednikov
3c6e090ae3 ci: test broken -autofree 2020-05-07 17:45:00 +02:00
Alexander Medvednikov
be063d740b ci: test self compilation with -autofree 2020-05-07 17:37:12 +02:00
yuyi
d096763f62
token: change 'STR' kind to 'string' 2020-05-07 16:26:22 +02:00
Tanel Liiv
d0afa748ff
cgen: optional multiple return values 2020-05-07 15:36:04 +02:00
Alexander Medvednikov
12221fb999 cgen: fix msvc struct init 2020-05-07 13:11:24 +02:00
Alexander Medvednikov
6ff93f270c cgen: simplify struct_init() 2020-05-07 13:00:42 +02:00
yuyi
78efe72c4c
checker: optimize check string cast error 2020-05-07 12:34:06 +02:00
Enzo Baldisserri
0f8ed84333
checker: verify interface is not used as receiver 2020-05-07 11:14:51 +03:00
yuyi
2f52106253
parser: use .next instead of .check, when a token is already known 2020-05-07 07:51:36 +03:00
Uwe Krüger
59aa31cee5
cgen: string interpolation: optimize away some partial strings of 0 length 2020-05-07 04:34:18 +02:00
wilesun
19390871e9
json: handle external types 2020-05-07 04:33:19 +02:00
yuyi
98a1b2782b
parser: simplify import 2020-05-07 04:32:29 +02:00
Delyan Angelov
e33805b2b3 json.decode: fix expressions in the second argument, also fixes news_fetcher.v 2020-05-06 21:44:50 +03:00
Tanel Liiv
b5a1544bf8
parser: allow re-assigning fns to variables 2020-05-06 20:09:29 +02:00
Delyan Angelov
f638caef39 compiler: v -autofree can now compile itself 2020-05-06 19:03:51 +03:00
Delyan Angelov
88ef0a75e2 ci: pass V_CI_MUSL=1 on musl CI jobs 2020-05-06 15:10:47 +03:00
Alexander Medvednikov
8d2a4d2436 clipboard: make compile on linux 2020-05-06 12:00:52 +00:00
Alexander Medvednikov
25db5e96a3 strings.builder: fix a memory leak 2020-05-06 11:12:00 +00:00
Don Alfons Nisnoni
e87289f24d
Fix typo on checker 2020-05-06 13:57:40 +03:00
Alexander Medvednikov
f80876497e fmt: use the new mut syntax in args 2020-05-06 12:43:46 +02:00
Alexander Medvednikov
b4c93349e8 checker: fix interface name check 2020-05-06 12:32:44 +02:00
Alexander Medvednikov
cc66eb1194 parser/checker: check capital letters in interface names/methods 2020-05-06 12:26:00 +02:00
Alexander Medvednikov
99cf520bd4 parser: mut x Type syntax for args 2020-05-06 12:13:22 +02:00
yuyi
51f3f31a4e
checker: check string(1) cast error 2020-05-06 12:05:24 +02:00
Enzo Baldisserri
215657e16a
checker: check interface implementation 2020-05-06 11:29:37 +02:00
yuyi
b627bb933c
message: use uniform message reference format 2020-05-06 09:10:40 +03:00
yuyi
c653977c15
cgen: fix struct with map field str() error 2020-05-06 09:08:48 +03:00
Alexander Medvednikov
67351c74c8 V 0.1.27 2020-05-06 02:26:43 +02:00
Enzo Baldisserri
c1f224640f
checker: verify that there is a main module 2020-05-06 00:09:46 +02:00
Alexander Medvednikov
25b536d03f cgen: str: do not free "true"/"false" literals 2020-05-05 23:25:14 +02:00
Alexander Medvednikov
473ffb5489 builtin: fix a leak in array_str 2020-05-05 18:04:43 +00:00
Sandro Martini
50351eded8
tests: interface: minor fixes 2020-05-05 19:56:11 +02:00
Alexander Medvednikov
fd0f8d06f8 tests: valgrind: use correct flag 2020-05-05 17:55:11 +00:00
Delyan Angelov
9e715b8701 cgen: use c_name() while generating code for or {} 2020-05-05 19:28:25 +03:00
Alexander Medvednikov
ff88906e9a cgen: add new to reserved words 2020-05-05 16:50:59 +02:00
Delyan Angelov
ddb5a8e6e4 time: add specialized vpc_now_darwin to fix -os cross 2020-05-05 17:31:21 +03:00
Sandro Martini
dd2a1455dc
tests: add another function to the Animal interface 2020-05-05 16:27:05 +02:00
Tanel Liiv
b16281d6e4
cgen: pass around functions 2020-05-05 16:21:21 +02:00
Alexander Medvednikov
7e71799980 checker: check none properly 2020-05-05 15:29:52 +02:00
Alexander Medvednikov
a0ca68ce3f checker: do not allow string(int) 2020-05-05 15:26:42 +02:00
Alexander Medvednikov
c5d295c378 fmt: move struct init logic to a separate fn 2020-05-05 15:06:51 +02:00
Alexander Medvednikov
148661ead6 json: wrap up: encode_array() 2020-05-05 14:54:12 +02:00
Alexander Medvednikov
b3d7b0205a json: handle field attributes 2020-05-05 14:41:27 +02:00
Delyan Angelov
a3bc32f3e0 builder: use time.new_stopwatch instead of benchmark.new_benchmark (reduces exe size) 2020-05-05 15:31:38 +03:00
Alexander Medvednikov
ee92060d4d json: decode_array fix 2020-05-05 14:19:31 +02:00
Alexander Medvednikov
ef6c418eb6 json: decode arrays 2020-05-05 13:23:44 +02:00
Steve Phillips
84fc587ec2
cgen: use a temp var in map() 2020-05-05 10:29:23 +02:00
yuyi
6aca3be474
cgen: fix []map[string]string.str() error 2020-05-05 08:46:19 +03:00
Delyan Angelov
f9fe5b60a7 v doc: skip _x.c.v when not on x, i.e. filter files like v itself 2020-05-05 08:08:03 +03:00
Alexander Medvednikov
621cb7b914 parser: short struct init syntax 2020-05-05 02:12:51 +02:00
Uwe Krüger
a4b6c3fa5d
cgen: hex representation of signed and pointers 2020-05-05 00:24:33 +02:00
Steve Phillips
081338b8bf
checker.v: suggest []Type{}, not []Type 2020-05-05 00:20:32 +02:00
Delyan Angelov
1c945faa15 cgen: fix _to_Interface_INAME conversion fns generation 2020-05-05 00:01:54 +03:00
Delyan Angelov
b5fda6e410 cgen: skip interface outside methods, while generating _interface_methods struct 2020-05-04 22:56:58 +03:00
Alexander Medvednikov
32a7bd3a48 parser/checker: do not allow using private types from other modules 2020-05-04 21:56:41 +02:00
Alexander Medvednikov
9aa1a65489 checker: check match condition 2020-05-04 21:03:18 +02:00
Alexander Medvednikov
9823d80e0c json: minor fixes + bring back the test 2020-05-04 20:43:22 +02:00
Delyan Angelov
6e1825b417 cgen: prefix with v_ keyword C fn args too 2020-05-04 19:55:21 +03:00
joe-conigliaro
c9798d3918
table: fix check for fn with no args 2020-05-05 02:44:10 +10:00
joe-conigliaro
2bb995274e
table: make table.check ret false & update fn args check 2020-05-05 02:34:11 +10:00
Delyan Angelov
d7e7113047 cgen: fix for char in nums {} 2020-05-04 18:57:33 +03:00
joe-conigliaro
b2157388d9
checker: check method args 2020-05-05 01:32:40 +10:00
Delyan Angelov
36bf99ed5a parser: remove forgotten ----- line 2020-05-04 18:28:55 +03:00
Delyan Angelov
d30eefc3be fmt: improve handling of map[k]v and []map[k]v types 2020-05-04 18:27:07 +03:00
Alexander Medvednikov
fd8a194df0 json: wrap up decode() 2020-05-04 16:46:39 +02:00
Delyan Angelov
5eb71c4a13 fmt: initial support for -debug 2020-05-04 17:27:41 +03:00
Enzo Baldisserri
8fd69e845f
cgen: fix using pointer as interface receiver 2020-05-04 14:21:03 +02:00
Delyan Angelov
0e241162d9 panic: distinguish between builtin and main modules 2020-05-04 14:51:30 +03:00
Delyan Angelov
cdf70c070b tests: add panic_with_cg.vv/.out 2020-05-04 14:34:51 +03:00
joe-conigliaro
57903247e3
parser: add back struct field removed by accident 2020-05-04 21:27:54 +10:00
yuyi
90fc23ccfb
checker: fix array init []type{cap: x.len} error 2020-05-04 13:22:09 +02:00
Uwe Krüger
f831910c5c
utf: fix string length calculation for combining characters 2020-05-04 13:21:11 +02:00
joe-conigliaro
d75f286230
parser: store FnDecl body position and use for scope 2020-05-04 20:31:34 +10:00
joe-conigliaro
4571a5eb83
gen: use middle of fn pos to load correct scope for free 2020-05-04 20:08:37 +10:00
yuyi
c112b3aec5
tests: fix cleanup of compiler_test.v on windows 2020-05-04 11:33:54 +02:00
Alexander Medvednikov
eca24c5d11 tests: interface: rename Speaker to Animal 2020-05-04 10:58:42 +02:00
Delyan Angelov
acd80f052b
tests: improve diagnostic output on failure 2020-05-04 11:21:25 +03:00
yuyi
e0e064ff08
scanner: fix string slash line breaks error 2020-05-04 10:19:23 +02:00
yuyi
cd5dccd855
gen: fix compilter_test.v error on windows 2020-05-04 10:09:49 +02:00
Enzo Baldisserri
4b3ce79e84
interface: support arguments in methods and simplify 2020-05-04 00:14:59 +02:00
Delyan Angelov
71a92eb87b tests: fix CI failing for builtin __as_cast 2020-05-03 22:25:38 +03:00
Delyan Angelov
242670a33d compiler: add support for panic_debug with -cg 2020-05-03 22:13:59 +03:00
Delyan Angelov
0b750a234f repl: fix for single lines ending with // comment 2020-05-03 20:48:46 +03:00
Delyan Angelov
845ffb59a6 live: use mostly pure V code for reloading, eases customization 2020-05-03 20:22:24 +03:00
Uwe Krüger
4a096bd133
parser: fix string interpolation for default conversion 2020-05-03 18:12:59 +02:00
Alexander Medvednikov
de749e9d3b parser/cgen: interface <<; any type 2020-05-03 18:08:45 +02:00
Alexander Medvednikov
2a016d03ac checker: use []int instead of array_int in errors 2020-05-03 16:49:05 +02:00