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

365 Commits

Author SHA1 Message Date
joe-conigliaro
5fb3c0e3a8 compiler: add error when embedding struct in itself 2019-09-30 13:41:11 +03:00
Delyan Angelov
e72fe25224 compiler: more precise 'declared and not used' error positioning
* compiler: extract and cleanup error handling functionality into its own file compiler/compile_errors.v

* compiler: implement p.error_with_token_index and p.warn_with_token_index and use them. Fix tests.

* tools/performance_compare: add a 'Source lines in compiler/' line

* MSVC does not have STDOUT_FILENO nor STDERR_FILENO ...
2019-09-29 20:37:39 +03:00
hazohelet
6d483c0a56 parser: float1 == float2 uses machine epsilon by default 2019-09-29 18:27:53 +03:00
Alexander Medvednikov
83022a2478 fix pushing to mutable array args 2019-09-29 17:02:28 +03:00
Alexander Medvednikov
ee8ff39454 rename ModPath to v_modules_path; do not allow long variable names without _ 2019-09-29 05:34:17 +03:00
Delyan Angelov
8b8cd13929 parser: add some infrastructure for more specific errors
* compiler: change s.line_nr in just one place, so that s.last_nl_pos will be updated in tandem too.

* Cleanup spurious spaces.

* Store ScannerPos info inside the cached tokens.

Use the stored information when errors are encountered.

* Fix #2079 ( cannot use type...in assignment ).

* do not store scannerpos per each token, instead rescan the source once on error to get the position.

* compiler: implement highlighting for errors. Use only line/col info stored in the cached tokens.

* fixing building on windows

* Split can_show_color to _nix and _win files.
2019-09-29 04:33:23 +03:00
Alexander Medvednikov
ed93185cb7 fix base64 test 2019-09-28 22:23:22 +03:00
Alexander Medvednikov
9eac16b976 parser: struct names must be capitalized 2019-09-28 22:20:34 +03:00
Delyan Angelov
a4cbe78d97 compiler: streamline main function handling
* compiler: streamline C main function generation

* fix most tests

* compiler: fix for 'go update()' in graph.v . More precise parser error messages.

* Fix temporarily examples/hot_reload/message.v by using os inside it (os.clear).

* Make graph.v easier to quickly modify by defining y outside the loop.

* Fix failure of /v/nv/compiler/tests/defer_test.v when run with 'v -g' (#line directive was not on its own line, but right after } ).

* Do not pass the os.args to tests, even if the tests import os (they are more stable when run in a controlled environment).

* fix declared and not used in the js backend.

* fix js main => main__main too.
2019-09-28 20:42:29 +03:00
joe-conigliaro
ed3a4961d0 compiler: blank identifier for loops. dont declare any variables 2019-09-28 19:53:56 +03:00
Swastik Baranwal
7952d591b9 parser: Update Division or Modulo by Zero Message 2019-09-28 19:52:52 +03:00
lutherwenxu
5c79c0e743 compiler: enforce reserved keywords replacement
* compiler: Enforce reserved keywords replacement on empty value initialization

* compiler: Add test for reserved keywords enforcement

A new struct has been introduced in the tests that contains all C reserved keywords that are not reserved in V. Some read and write are tested too.
2019-09-28 14:13:09 +03:00
joe-conigliaro
0fc9ada0aa parser: use actual blank ident for consts 2019-09-28 13:59:54 +03:00
luoheng
5348c667cc compiler/parser: fix single element in array error 2019-09-28 13:50:30 +03:00
joe-conigliaro
802da8f31d compiler: clean up. remove new_parser_string_id (#2140)
* clean up

* fix comment

* fix comment
2019-09-28 04:56:05 +03:00
Alexander Medvednikov
dd58298500 compiler: fix interfaces after the recent tokens change 2019-09-27 21:01:08 +03:00
unknown-v
14a8d4ae3c parser: replace "≠" with "!=" 2019-09-27 18:55:30 +03:00
joe-conigliaro
ad99b82930 compiler: make vgen use strings.Builder & allow parser creation from string 2019-09-27 14:02:01 +03:00
Alexander Medvednikov
8cbfd7a9da parser: partial interface fix 2019-09-27 06:03:54 +03:00
Alexander Medvednikov
8f9c0b621e parser: fix columns in errors 2019-09-27 05:27:57 +03:00
Alexander Medvednikov
da43267e09 parser: cached tokens (second step) 2019-09-27 04:01:12 +03:00
Alexander Medvednikov
a45255337d bring back "parser: cache tokens (first step)"
This reverts commit 0fcdd7db35.
2019-09-27 04:00:48 +03:00
Alexander Medvednikov
0fcdd7db35 Revert "parser: cache tokens (first step)"
This reverts commit 8992707fbb.
2019-09-26 06:05:18 +03:00
Alexander Medvednikov
8992707fbb parser: cache tokens (first step) 2019-09-26 05:20:08 +03:00
Alexander Medvednikov
04e4018228 compiler: small fixes + some logic for freeing strings 2019-09-26 03:24:58 +03:00
joe-conigliaro
d4bae356ba compiler/vlib: add error for no new vars in loop ("_,_") & remove "." from errors 2019-09-25 17:59:50 +03:00
joe-conigliaro
8974aa4513 compiler/vlib: change _ := to _ = and disable _ := 2019-09-25 15:10:45 +03:00
joe-conigliaro
746655c1d5 compiler: re assignable blank identifier _ & no longer a variable 2019-09-25 14:53:44 +03:00
Alexander Medvednikov
55d09d23b4 compiler: rename cerror() to verror(); some small optimizations 2019-09-24 19:38:04 +03:00
joe-conigliaro
3317d7fd7c compiler: clean up multiple returns and verify number of returned values 2019-09-24 13:14:04 +03:00
joe-conigliaro
a44a03f9a5 compiler: fix mark_var_used() 2019-09-24 06:18:06 +03:00
Alexander Medvednikov
d74c91616f remove all p.log()'s 2019-09-23 23:18:55 +03:00
Alexander Medvednikov
d2d75f3824 parser: do not allow "int?", only "?int" 2019-09-23 23:17:06 +03:00
Alexander Medvednikov
f27f3515ae compiler: optimize mark_var_used() etc 2019-09-23 23:06:40 +03:00
Alexander Medvednikov
8d52d877fb compiler: free local_vars 2019-09-23 22:16:52 +03:00
Alexander Medvednikov
bf1ee28194 ui: Objective-C @interface support for Cocoa; minor clean-ups 2019-09-23 15:54:17 +03:00
joe-conigliaro
422ba3a3ce compiler: unused module check always 2019-09-23 15:11:05 +03:00
joe-conigliaro
23c84516e2 compiler: error on unused imports 2019-09-23 13:42:20 +03:00
joe-conigliaro
23e30962b9 compiler: multiple returns - add test & fix use with array/map 2019-09-23 13:39:35 +03:00
joe-conigliaro
60d932e57d compiler: functions with multiple returns 2019-09-23 05:45:19 +03:00
Alexander Medvednikov
b4207e1be7 compiler: allow "u64_var == 0" without casting the const literal 2019-09-23 02:14:10 +03:00
Delyan Angelov
7421781150 CI: split jobs into more steps; compiler: fix "v test v" with tcc 2019-09-22 17:24:15 +03:00
luoheng
f1d5f8e2bf parser: allow ! only with bools 2019-09-21 18:21:45 +03:00
Henrixounez
ffcff9ebd4 builtins: ustring comparisons, concatenation and other functions 2019-09-20 19:07:38 +03:00
Delyan Angelov
f042dfb861 compiler: fix line numbers in unused variable error messages 2019-09-20 13:42:37 +03:00
Alexander Medvednikov
b6bb6a5a60 do not allow go print() 2019-09-19 18:02:31 +03:00
Alexander Medvednikov
ad6ab39287 table: use ?Var in find_const() 2019-09-19 14:19:44 +03:00
Alexander Medvednikov
f629069572 autofree: free strings 2019-09-19 14:04:27 +03:00
Alexander Medvednikov
cb31eeec55 compiler: first step to require explicit definition of imported C fns 2019-09-19 05:16:25 +03:00
Alexander Medvednikov
13e4c79f58 table: use optional in find_method() 2019-09-19 04:56:22 +03:00
Danil-Lapirow
b0092235fc parser: fix a more complicated "in" usage 2019-09-18 16:13:22 +03:00
joe-conigliaro
695d4018ea compiler: let attributes work with pub functions 2019-09-18 15:32:55 +03:00
Alexander Medvednikov
040d03912b table: use an optional for find_fn() 2019-09-18 15:06:34 +03:00
Alexander Medvednikov
d180324413 find_field: use optional 2019-09-18 14:28:11 +03:00
Alexander Medvednikov
d1500511e6 "none" keyword for optionals + more memory fixes 2019-09-18 14:15:10 +03:00
Alexander Medvednikov
ecffa8e1d9 v.js: fix for .. 2019-09-17 22:21:44 +03:00
Alexander Medvednikov
1397d532c6 compiler: check if mutable receivers are modified 2019-09-17 13:10:43 +03:00
joe-conigliaro
cbd4478b5e compiler: fix msvc empty struct & enable travis msvc 2019-09-16 13:01:07 +03:00
Alexander Medvednikov
3db4d66824 operator | not defined on bool 2019-09-15 19:35:48 +03:00
Alexander Medvednikov
48c05b5a45 cgen: use *char in all functions with *char args to avoid warnings 2019-09-15 18:56:33 +03:00
Alexander Medvednikov
5cc81b91cb JavaSript backend (early stage) 2019-09-15 03:49:57 +03:00
Alexander Medvednikov
3d2c266980 compiler: -autofree flag 2019-09-14 18:54:55 +03:00
Alexander Medvednikov
682eedce59 compiler: remove the temporary windows check 2019-09-14 18:34:59 +03:00
Henrixounez
c604a5c02f compiler: no free on stack allocated array 2019-09-14 13:40:59 +03:00
joe-conigliaro
b96cbe2177 compiler: temporary memory fix on windows 2019-09-14 13:09:25 +03:00
Alexander Medvednikov
21f3b9eccc compiler: do not free memory on Windows for now 2019-09-13 16:27:09 +03:00
Alexander Medvednikov
9dd86f6fb8 compiler: more memory logic + replace "cur_fn &Fn" with "cur_fn Fn" 2019-09-13 15:47:31 +03:00
joe-conigliaro
41734affb3 compiler: detect typos in function/variable/module names 2019-09-13 14:10:24 +03:00
BigBlack
8fe46d5db5 compiler: call string method in C funtion parameter 2019-09-13 02:41:51 +03:00
Alexander Medvednikov
9853323157 array: make ".contains()" private, use "in" everywhere 2019-09-11 15:12:13 +03:00
BigBlack
e6354567e5 compiler: fix sizeof and cc 2019-09-11 13:34:19 +03:00
Delyan Angelov
0ade45db08 compiler: print the offending source line on error 2019-09-10 13:08:43 +03:00
Alexander Medvednikov
7fc678c961 fix urllib_test.v 2019-09-09 14:21:18 +03:00
Alexander Medvednikov
00687de43b memory: clean up all arrays in the V compiler 2019-09-09 13:55:47 +03:00
Alexander Medvednikov
a6ec6e23bc bf: minor clean up 2019-09-09 02:31:43 +03:00
Alexander Medvednikov
71224ad17c compiler: fix building_v 2019-09-08 17:19:42 +03:00
Alexander Medvednikov
a6f927a6e9 bring back automatic array_free() 2019-09-08 14:50:18 +03:00
Delyan Angelov
d5665997e0 compiler: @FILE, @LINE, @FN, @COLUMN 2019-09-07 13:44:41 +03:00
Alexander Medvednikov
76a89c832e parser: small optimizations 2019-08-26 01:19:39 +03:00
BigBlack
7cf058feac parser: function pointers 2019-09-05 12:09:41 +03:00
Henrixounez
726fcb5eec compiler: check if-expressions returning only one type 2019-09-05 12:08:40 +03:00
Danil-Lapirow
c6f7479a72 parser: add return dropping to false to check whether statements return 2019-09-04 19:48:01 +03:00
Danil-Lapirow
5c43bfbf13 parser: add additional paren for multi case branch 2019-09-04 19:47:37 +03:00
joe-conigliaro
6921c15b7b compiler: fix repl chained_fields test (windows) 2019-09-03 18:42:40 +03:00
Joe Conigliaro
1f67d9edd8 fix bugs breaking tests 2019-09-03 15:21:52 +03:00
Delyan Angelov
d681e1cae3 compiler: fix deprecation message for u8. 2019-09-02 21:04:27 +03:00
F1ssi0N
892c948a44 Make sure to actually generate the empty struct declaration 2019-09-02 15:33:03 +03:00
Alexander Medvednikov
1c6d51f271 remove u8 and i32 from tests and examples 2019-09-02 15:02:25 +03:00
Alexander Medvednikov
0db1eaa55a parser: get_type2() for the upcoming type system refactoring 2019-09-02 14:55:26 +03:00
Alexander Medvednikov
0e2c41e0f9 replace *Foo with &Foo everywhere 2019-09-01 22:51:16 +03:00
Alexander Medvednikov
aaab24dcf8 use &Foo instead of *Foo warning 2019-09-01 22:45:06 +03:00
Alexander Medvednikov
59ba551d3b u8 + i32 warnings 2019-09-01 22:41:29 +03:00
Alexander Medvednikov
d078aa360b parser: use map[string]Type instead of []Type 2019-09-01 22:30:49 +03:00
Delyan Angelov
011afeb2ea compiler: fix building v with tcc on linux 2019-09-01 14:12:37 +03:00
Alexander Medvednikov
bfa6505636 compiler: replace &Type with Type 2019-09-01 14:05:03 +03:00
teggot
c04cca1ae4 Allow use FP without calling it 2019-09-01 02:20:35 +03:00
Alexander Medvednikov
0a4a1ca36c compiler: simplify a[index] = val 2019-08-31 13:30:08 +03:00
teggot
b6ecbd8bc3 Check for type, not name 2019-08-31 11:47:55 +03:00
Alexander Medvednikov
29b4114bc0 compiler: simplify [0; n] 2019-08-31 01:34:43 +03:00
Emily Hudson
04a200d3d8 compiler: fix array initialisation generation for msvc 2019-08-31 00:59:21 +03:00