Commit Graph

1576 Commits (d24dce8eb33d60395e8dd8326bbfd0e81a0bcf7b)

Author SHA1 Message Date
Tim Basel 10efe47f03
parser: add support for mutable if guards (#13132) 2022-01-11 15:32:58 +02:00
yuyi 86ba4517b1
parser: check error of anon fn argument type (#13103) 2022-01-09 16:15:34 +02:00
Ken 9cbfa882e6
ast: support attributes for `ast.SumType` (#13010) 2022-01-08 17:35:10 +03:00
Delyan Angelov 5717066147
ci: fix `$tmpl` regression detected by gitly tests (after a73e146) 2022-01-07 19:19:31 +02:00
Artem a73e1462f0
tmpl.v: fix of is_html_open_tag function and allow usage of V template sign '@' in JS code (#13067) 2022-01-07 14:31:32 +02:00
Delyan Angelov 8088f462c9
parser: fix parsers producing codegen statements (for `[flag] enum MyEnum{}`) with mixed scope 2022-01-06 18:02:52 +02:00
Alexander Medvednikov 59ed4be49a all: update copyright year 2022-01-04 12:21:12 +03:00
pancake 4b55800ffd
v.eval: add tests and fix runtime cast crash (#13019) 2022-01-03 18:30:42 +02:00
Delyan Angelov 9278d4ec19
docs: fix a typo 2022-01-02 09:18:24 +02:00
Alexander Medvednikov 0e1cfd4a28 checker: simplify type sizeof check and fix c2v globals 2022-01-01 19:56:13 +03:00
yuyi cc577e1bfb
parser: check variable redefinition error (#12992) 2021-12-29 13:44:08 +02:00
Delyan Angelov 43fee6b3d5
all: fix registration of methods with the same name on different generic structs 2021-12-28 21:42:48 +02:00
Alexander Medvednikov 6176ce9f03 all: c2v fixes 2021-12-28 08:00:56 +03:00
Delyan Angelov 14648fa41e
parser: reduce max_expr_level to 310 (due to more limited stack size on windows) 2021-12-27 20:21:58 +02:00
Delyan Angelov a2eb90ee4e
parser: prevent too deep recursions in p.check_undefined_variables 2021-12-27 12:30:17 +02:00
Daniel Däschle 35282396ec
all: inline sum types (#12912) 2021-12-25 18:26:40 +03:00
Delyan Angelov db1175e455
parser: handle `[noreturn]` on methods too 2021-12-22 19:58:37 +02:00
penguindark 278c08704c
all: support slices with negative indexes `#[start..end]` (gated arrays) (#12914) 2021-12-22 16:34:02 +03:00
zakuro 2693631643
parser: make codegen generate correct module name (#12929) 2021-12-22 10:55:57 +11:00
joe-conigliaro 07cf6d9f96
parser/scanner: make codegen impl use own parser. closes #12857 (#12925) 2021-12-21 19:48:06 +02:00
yuyi cd0b581445
ast: rename 'table.get_type_symbol()' to 'table.sym()' and more related calls (#12898) 2021-12-19 18:25:18 +02:00
ChAoS_UnItY 50d988ebc7
v.parser: forbid unsupported language functions/types in specific backends (#12655) 2021-12-18 10:00:31 +02:00
Delyan Angelov 6ff953d936
preludes,builder,cgen: add support for VTEST_RUNNER=tap and -test-runner tap (#12523) 2021-12-16 15:59:46 +02:00
Delyan Angelov df7f2aa8a3
all: support `[markused]` tags for fns/consts/globals 2021-12-15 14:34:49 +02:00
zakuro eed882950c
fmt: remove extra comma of branch instead of parse error (#12814) 2021-12-14 08:14:43 +02:00
Delyan Angelov 79de408ef0
parser,checker: support `[generated] module xyz` (turns off notices). Use it for `infix.v`. 2021-12-12 00:58:38 +02:00
Thomas Mangin 0d0d7323bb
transformer: provide direct_memory_access to arrays when safe (#12724) 2021-12-11 21:55:46 +02:00
yuyi 7fc9e614a3
ast, parser, checker: fix generic fn in builtin module (#12769) 2021-12-09 21:37:43 +02:00
yuyi e433badcb8
parser, cgen: fix multiple comptime tmpl in one function (#12757) 2021-12-08 11:12:02 +03:00
yuyi c29a3cf6e8
parser: fix (absolute path) error (#12747) 2021-12-07 11:33:53 +02:00
Tim Basel c23ebec944
parser: support bool values in attributes (#12750) 2021-12-07 12:11:29 +03:00
Tim Basel 6d14275106
parser: support dot prefix for attributes (#12744) 2021-12-07 01:32:29 +03:00
Delyan Angelov 3ab82a23c5
tools: cleanup the output of V, compiled with `-d trace_parser` and `-d trace_checker` 2021-12-06 09:54:53 +02:00
Delyan Angelov 229d2fb667
v.util.timers: improve tracing by supporting `-d trace_timers_creation` 2021-12-05 11:55:41 +02:00
Leo Developer ace63594bf
all: support `$embed_file('embed.vv', .zlib)` (#12654) 2021-12-04 19:43:19 +02:00
pancake 8ac7739db8
parser: forbid empty match statements 'match cond.op {else {}}' (#12618) 2021-11-30 09:32:48 +02:00
Leo Developer 0f59d88ba6
v.embedfile: make path public (#12614) 2021-11-29 16:32:42 +02:00
Delyan Angelov 6d97b0a407
checker: improve checking of a << b, when a and b are numbers (#12589) 2021-11-29 03:48:49 +03:00
Delyan Angelov d431145a39
v.util,tools: use os.join_path_single 2021-11-22 21:42:55 +02:00
Delyan Angelov 3caeadfa0d
cgen,vfmt: support `[weak]` tags for functions and globals 2021-11-18 18:32:39 +02:00
zakuro b5e410e408
fmt: format explicit map init with parameter (#12499) 2021-11-18 08:34:30 +03:00
playX 2eb02ff5a7
jsdom, js: start refactoring jsdom; improve JS interfaces; add two attributes for them (#12488) 2021-11-17 11:41:33 +02:00
yuyi 5a89c0a480
ast: change CompFor to ComptimeFor (#12482) 2021-11-17 08:29:43 +02:00
Delyan Angelov 045579fd8a
parser: use the `[has_globals]` module attribute, remove the parser `global_enabled_mods whitelist` (part 2) 2021-11-16 11:44:36 +02:00
Delyan Angelov f0f5f97e9f
parser: support a `[has_globals]` module attribute, to eliminate a parser whitelist (part 1) 2021-11-16 11:34:26 +02:00
yuyi c28041cecc
all: cleanup/rename all `comp_` names to be `comptime_` (#12467) 2021-11-15 15:47:29 +02:00
playX 6c32c544e1
js,parser: allow declaring methods on JS interfaces for easier FFI (#12447) 2021-11-13 11:08:17 +02:00
playX a4c57ba56e
js: support JS interfaces (#12426) 2021-11-11 14:36:32 +02:00
yuyi 8f4180ea09
parser: check generic parameters error of generic struct declaration (#12418) 2021-11-09 09:25:57 +02:00
Delyan Angelov 1c12186701
v.token,ast,scanner,parser: use a KeywordsMatcher lookup for builtin_type_names searches too 2021-11-07 16:39:40 +02:00
Delyan Angelov a27833ed0d
all: support `volatile field Type` in struct declarations 2021-11-04 09:45:50 +02:00
Delyan Angelov c4e282a0c8
parser: check fn args in declarations too with `-Wimpure-v`
`v -Wimpure-v examples/2048/` now passes cleanly.
2021-11-03 16:20:24 +02:00
Delyan Angelov 6937074e7a
strings,builder: reduce V cgen and parser memory consumption, fix strings.Builder leak (#12342) 2021-10-31 12:58:55 +02:00
Delyan Angelov 4c67c01e72
parser,util: improve libleak false positive detection rate 2021-10-29 16:42:55 +03:00
Delyan Angelov b1bb1d361a
ci: vfmt parser.v 2021-10-28 10:51:55 +03:00
Delyan Angelov 1b6cccaf6d
parser,checker: allow a goto label right after return 2021-10-28 10:40:31 +03:00
yuyi 943a807d30
parser: implement generics method with auto multi generic types (#12312) 2021-10-27 15:41:13 +03:00
Wertzui123 ea6d2d53db
parser: disallow `for mut in range` (fix #12234) (#12277) 2021-10-27 14:55:36 +03:00
Lucas Jenß d7fd4a563b
parser: remove commented out debug statement (#12316) 2021-10-27 14:30:22 +03:00
Delyan Angelov f2cda1a529
parser: update p.inside_or_expr consistently (fix `v fmt -w vls/analyzer/symbol_registration.v`) 2021-10-19 13:36:10 +03:00
yuyi 6aca360507
parser: fix checking unexpected name (#12233) 2021-10-19 12:27:59 +03:00
playX a3de67de28
js: support WASM interoperability using `wasm_import`/`wasm_export` fn tags (#12212) 2021-10-18 10:56:21 +03:00
ChAoS_UnItY 4d1307f29b
all: index accessor in array init expression (#12181) 2021-10-15 03:57:49 +03:00
yuyi c9b2f878b3
parser, checker: optimize checking generic struct type mismatch (#12179) 2021-10-15 00:11:31 +03:00
Delyan Angelov 4c2cb1b6df
vdoc: prevent leaking to the docs the `pure_v_but_overriden_by_` prefix 2021-10-14 11:47:50 +03:00
Alexander Ivanov 0386f2bbea
checker: add an interface check for mutability, fixes #1081, fixes #7038 (#11963) 2021-10-11 15:41:31 +03:00
ChAoS_UnItY 3647fc6633
parser: perform constant folding before checking size of fixed array (#12126) 2021-10-10 01:55:25 +03:00
pancake 32259af2c9
v.parser: improve error message when no arch is set 'asm{}' (#12093) 2021-10-07 03:44:27 +03:00
yuyi f1742a6f62
v.ast: change 'type.to_ptr()' to 'type.ref()' (#12086) 2021-10-06 20:49:39 +03:00
crthpl 7cf9c198fe
asm: add segment addressing and fix [10] (#12068) 2021-10-05 18:57:15 +03:00
yuyi 82e6d6e51d
cgen: fix threads array wait without go calls (fix #12009) (#12050) 2021-10-03 18:24:44 +03:00
crthpl 85b58b03a3
cgen: parallelize (#10844) 2021-09-28 10:28:04 +03:00
Delyan Angelov 6a2ef733de
v.parser: add a generated `.all(.flag1|.flag2)` method to `[flag]` enums
Unlike `.has(.flag1|.flag2)`, which is true, for any of `.flag1` or `.flag2`,
the new method `.all()` tests whether *all flags* are set at the same time.
2021-09-26 21:40:44 +03:00
Delyan Angelov bf2569a9a8
all: support `mut volatile x := 123` declarations (#11940) 2021-09-22 13:06:30 +03:00
yuyi 108a01d65f
fmt: fix unnecessary line break in array init (fix #11448) (#11562) 2021-09-21 16:20:09 +03:00
ChAoS_UnItY 95136cbfc7
all: add unsigned shift operators (#11536) 2021-09-21 14:02:17 +03:00
Alexander Medvednikov f6bdc6b87e tmpl: fix <div> inside <div> 2021-09-21 07:54:10 +03:00
Enzo b2ecca3966
all: remove `size_t` (#11478) 2021-09-21 02:12:38 +03:00
05st f9f4867c25
tmpl: fix $tmpl comptime operation only working in return statement (#11541) 2021-09-19 23:22:26 +03:00
yuyi 8862c3af0f
all: implement `if foo in [Foo1, Foo2, Foo3]` (#11486) 2021-09-14 15:56:12 +03:00
Daniel Däschle b63ec8fbcf
checker: require `params` attribute to use struct as keyword arguments in function (#11135) 2021-09-14 00:05:30 +03:00
playX b9dfc89aa9
js: prefix V builtin functions, so they do not overlap with JS (#11483) 2021-09-13 11:44:55 +03:00
Enzo ccf6285f82
checker: allow mut arg on C functions (#11430) 2021-09-11 14:25:38 +03:00
Daniel Däschle be0c54caf9
checker: require or block for sumtype map (#11089) 2021-09-10 16:07:39 +03:00
yuyi af75789bbf
parser: fix reference var followed by block expr (#11456) 2021-09-10 15:31:09 +03:00
Dialga 66ef27a776
tmpl: fix escaping @ (#11452) 2021-09-09 20:27:24 +03:00
Alexander Medvednikov ab3adf3346 checker: no longer allow automatic dereferncing in `a = b` 2021-09-09 20:21:01 +03:00
Enzo bef3390f36
builtin: fix compilation (#11445) 2021-09-08 14:19:21 +03:00
Enzo e3b65092d6
parser: deprecate `size_t` (#11443) 2021-09-08 13:09:32 +03:00
Ruofan XU 892971024e
parser: fix generic detection of `foo < bar<T>()` (#11434) 2021-09-08 05:54:15 +03:00
Enzo 79c2bca401
v.scanner: fix error messages with unexpected token `?` (#11428) 2021-09-07 20:46:56 +03:00
Ned Palacios aedb6b8e84
v.builder: implement a `-check` mode, that runs only the parser + the checker, without codegen (#11414) 2021-09-07 07:17:53 +03:00
Dialga 905c292a81
tmpl: enforce stricter line checking for html interpolation (#11413) 2021-09-07 02:21:23 +03:00
Dialga 87f38bf6e7
tmpl: don't trim whitespace and escape \ (#11393) 2021-09-06 03:12:53 +03:00
zakuro 19a43db2de fmt: fix removal of comment before embed in struct (#11384) 2021-09-04 11:02:04 +03:00
Delyan Angelov 37b4553f52
v.parser: fix running `math` programs, from V installed in folders containing `.v` 2021-08-31 09:16:12 +03:00
yuyi 187c1c160b
parser: minor cleanup in comp_call() (#11311) 2021-08-26 07:57:10 +03:00
Delyan Angelov ec196cfcd1
all: support overriding individual function from .v files in .c.v or .js.v files. 2021-08-22 15:51:26 +03:00
yuyi 3d22dc1608
all: fix formating Foo<A,B> to Foo<A, B> (#11225) 2021-08-18 17:17:21 +03:00
Leo Developer b3094b0667
checker: abort prematurely on too many errors (#11185) 2021-08-15 13:41:51 +03:00
Leo Developer 8a8a0932f7
all: add limit to accumulated errors / warnings (#11183) 2021-08-14 19:49:21 +03:00
Delyan Angelov deb26b92b9
cgen: support `typeof(x).idx`, as well as `iface.type_idx()` (#11178) 2021-08-14 17:22:25 +03:00
Delyan Angelov 900c37aa65
v.gen.c: support `T.typ` - an int for the type index of the generic type `T` (#11175) 2021-08-14 08:48:25 +03:00
Daniel Däschle 6dbc6f233b
v.parser: add checks for interoperability (C. or JS.) function declarations (#11140) 2021-08-12 10:47:24 +03:00
yuyi 89a8854e57
v.parser: fix generics type name in if_expr (#11156) 2021-08-12 10:19:06 +03:00
Enzo da53f818df
all: initial support for closures (x64 / linux-only) (#11114) 2021-08-10 21:27:15 +03:00
yuyi 1d3786ff1e
v.parser: fix `if a == Abc{} {` (#11092) 2021-08-07 18:05:22 +03:00
Daniel Däschle 8d2567740b
parser: make [..] work (#11064) 2021-08-06 03:54:24 +03:00
Daniel Däschle f59119485a
v.parser: add check for existing type on sum type declaration (#11054) 2021-08-04 18:14:16 +03:00
yuyi 5162c257a2
v.parser: minor cleanup in parse_type.v (#11047) 2021-08-04 12:49:36 +03:00
Daniel Däschle 800c0e5092
vlib: remove deprecated map{} usages as well as deprecated functions (#11035) 2021-08-04 12:44:41 +03:00
Daniel Däschle 815c4b7420
all: rename generic_struct_inst to generic_inst (#11044) 2021-08-04 03:37:27 +03:00
Florian Blasius 69f31d8d5c
checker: check int literal to enum cast (fix #10125) (#10348) 2021-08-02 07:12:29 +03:00
Uwe Krüger 6068777e03
parser/checker: deduce type of global from initialization expression (#11005) 2021-07-31 16:35:19 +03:00
Uwe Krüger 08aa6c08f6
all: more improvements for global variables (#10986) 2021-07-29 10:57:31 +03:00
yuyi cb7be87d4e
parser: fix struct init and assign using `sql` variable (#10968) 2021-07-26 21:14:31 +03:00
zakuro 3979e5c5ff
v.parser: show better position for sort struct init warning (#10939) 2021-07-24 20:41:59 +03:00
Uwe Krüger 1e5627e777
parser: don't require unary `>` prefix for `select` timeout (#10928) 2021-07-23 23:24:27 +03:00
shadow fe5e3c452f
parser: disable generic type aliases (#10917) 2021-07-23 01:17:16 +03:00
Lukas Neubert 38100faecf
fmt, parser: fix pos.last_line for assembly blocks (#10877) 2021-07-21 11:48:12 +03:00
Daniel Däschle ad3835b598
parser: deprecate short struct init (#10842) 2021-07-20 11:17:08 +03:00
Daniel Däschle 9127e202d5
v.parser: fix error on empty name expr (#10860) 2021-07-19 17:09:51 +03:00
playX 425ca5e3c3
v.gen.js: add three backend options for JS, and comptime if support (#10859) 2021-07-19 15:55:03 +03:00
yuyi a5c784830b
all: simplify global_scope processing (#10848) 2021-07-18 15:29:34 +03:00
Delyan Angelov 6edfb2c7fe
v.parser: eliminate PrefixExpr from `&Type(x).name` and `&Type(x)[idx]` too (fix vinix build) 2021-07-17 20:20:20 +03:00
Delyan Angelov fc8a8e3b6f
ci: fix failure for function_stored_in_global.vv 2021-07-17 18:19:20 +03:00
Delyan Angelov 568aa742b2
v.parser: improve conditions for debugging ast.CastExpr parsing 2021-07-17 17:49:29 +03:00
yuyi 3a0fa550b6
checker: fix generics fn inferring map type (fix #10835) (#10839) 2021-07-17 17:49:21 +03:00
yuyi fe64346ae2
parser: minor optimization of array filtering judgement (#10821) 2021-07-16 12:00:37 +03:00
yuyi aca66d503d
parser: minor optimization in call_expr() (#10809) 2021-07-15 17:47:59 +03:00
spaceface 6e942bf4c2
v: initial support for generic interfaces and sumtypes (#10795) 2021-07-15 08:29:13 +03:00
Delyan Angelov bd0653abab
parser: cleanup `&Type(x)` more, add fmt regression test 2021-07-13 13:12:37 +03:00
crthpl 5089eb4a84
parser: fix pointer cast expressions hack (#10777) 2021-07-13 12:01:24 +03:00
shadowninja55 d1f1c5ae51
v doc: add attribute tags to `v doc -f html` (#10778) 2021-07-13 08:27:20 +03:00
yuyi 581280e6fc
parser: cleanup check_cross_variables() (#10754) 2021-07-12 12:10:42 +03:00
yuyi 938e9b61b5
parser: check undefined variables in assign_stmt (#10755) 2021-07-11 19:09:35 +03:00
yuyi 71e8237483
parser: check undefined variables in array inits (#10746) 2021-07-11 03:49:07 +03:00
Louis Schmieder eb96ad11d9
checker: add pkgconfig to comptime if (#10692) 2021-07-09 18:17:04 +03:00
crthpl d14de5fdaf
all: fix generic functions with pointer args (#10686) 2021-07-07 11:51:05 +03:00
Alexander Medvednikov 0f72bc9819 parser: temporary [c2v_variadic] fn attr for c2v'ed code 2021-07-05 11:32:15 +03:00
Delyan Angelov 972542d6ee
checker: `[noreturn]` part 2 (cleanup) (#10667) 2021-07-05 05:05:37 +03:00
Delyan Angelov 6aecda3be8
all: support `[noreturn] fn abc() { for{} }`, mark panic/1 and exit/1with it too. (#10654) 2021-07-04 20:24:19 +03:00
yuyi 2bcc733ff6
v.parser: rename pratt.v to expr.v (#10566) 2021-06-28 19:35:06 +03:00
shadowninja55 06a6a8e199
checker: check for empty branches in match expressions (#10593) 2021-06-28 19:32:28 +03:00
shadowninja55 2e5ed08558
v.parser: allow anonymous function to return a function (#10592) 2021-06-28 11:51:24 +03:00
shadowninja55 830cf4645c
v.parser: prohibit registering selectively imported (structs / enums / aliases / interfaces) (#10579) 2021-06-28 10:26:09 +03:00
shadowninja55 9b84faad6f
v.parser: prohibit redeclaration of imported functions (#10564) 2021-06-25 14:27:58 +03:00
shadowninja55 be8be3d319
v.parser: prohibit redeclaration of builtin types (#10563) 2021-06-25 13:08:56 +03:00
crthpl 500b48788e
parser, cgen: fix basic asm registers, fix numbered labels in addressing, support indirect branching (#10545) 2021-06-23 14:20:07 +03:00
Yuriy Zymlex 6736817bba
parser: fix `rewind_scanner_to_current_token_in_new_mode` (#10495) 2021-06-22 20:17:36 +03:00