Commit graph

106 commits

Author SHA1 Message Date
Delyan Angelov
424c453610
fix warning when compiling cmd/tools/vast/vast.v, add description of -s to ast.txt too 2025-02-05 15:59:55 +02:00
Delyan Angelov
94a97f6173
tools: implement an -s option for v ast, to skip all nodes with default values like [], {}, 0, false; with it v ast -pts examples/hello_world.v | wc -l is 36 lines 2025-02-05 15:53:56 +02:00
Felipe Pena
78effd0c09
type_resolver: refactor resolve_comptime_type (#23616) 2025-01-31 08:51:20 +02:00
Felipe Pena
45b79dfb97
vet: add an -I option to notice fns, with the potential to be inlined (#23534) 2025-01-22 15:58:02 +02:00
Delyan Angelov
9ae0a9db9b
v,ast,fmt,parser: support @[tag] for hash statements, like #define and #flag (#23210) 2024-12-20 08:49:03 +02:00
Felipe Pena
b1502d4ff1
parser,checker,cgen,fmt: fix array fixed option initialization (none) (complete #23164) (#23176) 2024-12-16 16:54:46 +02:00
Delyan Angelov
b801083f13
Revert "os: deprecate os.getwd in favor of os.get_current_dir (part 1) (#22966)"
This reverts commit 93009823f9.
2024-11-25 15:10:15 +02:00
Elsie
93009823f9
os: deprecate os.getwd in favor of os.get_current_dir (part 1) (#22966) 2024-11-25 12:17:33 +02:00
Felipe Pena
3278614abb
parser,checker: improve static method call resolution (fix #22773) (#22787) 2024-11-07 19:46:51 +02:00
Felipe Pena
dab25cad49
cgen: remove unused code generated for unwrapping temp var from callexpr (detect unused return value from CallExpr), fix parser bugs (#22769) 2024-11-07 12:01:33 +02:00
Felipe Pena
cf03ecd0de
fmt: add support for comments inside sql db { ... } blocks (fix #22601) (#22602) 2024-10-21 12:08:04 +03:00
Delyan Angelov
988f8b487d
ci: fix failing jobs after 4ed9d13 (#22606) 2024-10-20 23:51:19 +03:00
Alexander Medvednikov
4ed9d13803 veb: translations via %translation_key 2024-10-20 21:35:27 +03:00
yuyi
e97036a25b
v: remove the automatic passing of structs with more than 8 fields by reference (related #17159) (#22547) 2024-10-17 11:04:23 +03:00
Delyan Angelov
b1142548b9
ast,parser,cgen: add a new ast.FnDecl field is_c_extern, set it during parsing, to be available in markused and checker too 2024-10-13 16:47:58 +03:00
Felipe Pena
5fcfc27e50
cgen: fix interface type generation for generic struct (fix #22186) (#22189) 2024-09-14 23:14:59 +03:00
yuyi
4bce71e12f
fmt: fix enum/struct_decl/struct_init fields with empty newlines (#22051) 2024-08-15 17:28:52 +03:00
yuyi
c51d30bf53
fmt: fix alignment of struct init fields (#22025) 2024-08-11 09:11:24 +03:00
yuyi
19f080ffb8
all: change single blank comment to blank line (#22016) 2024-08-09 14:55:58 +03:00
Delyan Angelov
62e2b7fbdb
fmt: keep manual newlines after fn parameters in fn declarations, do not auto wrap (#21795) 2024-07-03 17:33:48 +03:00
larpon
78b77b9f14
comptime: support -d ident=value and var := $d('ident', 0) (#21685) 2024-06-19 07:24:16 +03:00
yuyi
667f65bb5f
checker: check assigning immutable reference struct field (fix #20814) (#20883) 2024-02-22 19:22:13 +02:00
Felipe Pena
d2af0dc96a
cgen, ast, checker: fix auto deref arg when fn expects ref (#20846) 2024-02-16 22:04:34 +02:00
Delyan Angelov
804a7bdda5
vfmt,parser: keep the original import name in ast.Import, and use it without modifications for paths unders ~/.vmodules 2024-01-29 19:53:25 +02:00
Felipe Pena
9f6448e30e
v: $dbg statement - native V debugger REPL (#20533) 2024-01-19 07:10:17 +02:00
Tim Marston
bb9acf4261
vast,ast: output map init update expression (#20574) 2024-01-18 05:19:14 +02:00
Felipe Pena
e2aa9b358d
tools.vast: add missing LambdaExpr in v ast file.v (#19994) 2023-11-26 13:54:49 +02:00
Alexander Medvednikov
f09826e928 all: unwrap const() blocks 2023-11-25 10:02:51 +03:00
Delyan Angelov
f7b9e4eafd
vfmt: automate transition from the old [attribute] to the new @[attribute] syntax (#19912) 2023-11-17 17:43:29 +02:00
Joe C
757929392e
all: update attributes to use new syntax 2023-11-15 16:16:01 +11:00
Turiiya
2332c17bea
tools: fix typos (#19546) 2023-10-11 03:16:59 +03:00
yuyi
05d940ac2a
fmt: simplify formatting assign statement comments (#19524) 2023-10-08 13:32:22 +03:00
yuyi
e3ba197361
ast, parser, checker, cgen: cleanup ast.ArrayInit (#19526) 2023-10-08 13:31:52 +03:00
Tim Marston
756075380b
orm: add null handling and option fields (#19379)
* orm: added is none and !is none handling

* orm: added NullType, support option fields and deprecate [nonull]

Nullable DB fields are now determined by corresponding option struct field.  The
[nonull] attribute is deprecated and fields are all NOT NULL now, unless they
are option fields. New orm primitive, NullType, added to support passing none
values to db backends, which have been updated to support it.  Also, empty
string and 0 numberic values are no longer skipped during insert (since they may
be valid values).

* orm: fix [nonull] deprecation warning

* orm: add null handling to update and select

also, improved formatting for orm cgen, and removed optimised operand handling
of orm `is` and `!is` operators

* sqlite: read/report NULLs using new orm NullType

* postgres: returning data primitives now returns new orm.NullType

* orm: initialise NullType Primitives properly

* orm: do not smart cast operands inside sql

* orm: fix bad setting of option value

* orm: improve orm_null_test.v, adding/fixing selects

* orm: cleanup: rename NullType->Null, use serial const, cgen output

* orm: handle automatically generated fields more explicitly

During insert, fields which are
* [sql: serial]
* [default: whatever]
and where the data is a default value (e.g., 0, ""), those fields are not sent
to the db, so that the db can generate auto-increment or default values.  (This
was previously done only for [primary] fields, and not in all circumstances, but
that is not correct -- primary and serial/auto-increment fields are differnet.)

* orm: udpated README

* orm: select cgen fixes: read from uninit res; fail to init res

* orm: udpated tests

* orm: fix option sub-struct fields

* orm: fixed joins to option structs

Changed orm.write_orm_select() so that you pass to it the name of a resut
variable which it populates with the result (or not) and changed use of it in
sql_select_expr() and calls in write_orm_select() to populate substructs.

* orm: fix pg driver handling of NULL results

* orm: move runtime checks to comptime checker; cache checked tables

* orm: vfmt :(

* orm: markdown formatting

* orm: renamed orm.time_ and orm.enum_; updated db drivers

* checker: updated orm tests

* orm: fix issue setting up ast option values as orm primitives

* checker: ORM use of none/options and operations (added tests)

* orm: fixed tests

* db: clean code

* examples: remove orm nonull attributes

* orm: skip test memory santisation for orm_null_test.v

* orm: make the type-to-primitive converstion fns not public

* orm: mv object var c-code from checker->cgen; fix memory corruption

Code in checker/orm.v used the SqlStmtLine object field name to store c-specific
referenecs to option and array fields (for arrays of children).  I moved this
logic to cgen.  And fixed an issue introduced with option fields, where an array
of children was unpacked into a non-array result which could corrupt memory.

* orm: fixed vast error

* orm: skip 2 tests on ubuntu-musl which require sqlite3.h

* cgen: prevent casting a struct (string)

* v fmt orm_fkey_attribute.vv, orm_multidim_array.vv, orm_table_attributes.vv; run `VAUTOFIX=1 ./v vlib/v/compiler_errors_test.v`
2023-10-05 19:09:03 +03:00
Delyan Angelov
f3aec20000
all: support ; statements, allowing for oneliners like ./v -e 'import os; println( os.ls(os.args[1])!.sorted(a > b) )' vlib/math (#19345) 2023-09-15 00:44:15 +03:00
yuyi
a23f89e243
fmt: simplify the processing logic for removing inline comments (#19297) 2023-09-07 16:00:00 +03:00
yuyi
22bd1b9d55
ast: clean up ast.StructInit (#18518) 2023-06-22 16:41:08 +03:00
Delyan Angelov
cb5d5f8ca5
vast: fix segfault for fn main() { $compile_warn("WARN") } 2023-06-14 13:59:55 +03:00
yuyi
dd1d5bca1b
ast: clean up ast.StructInit (#18387) 2023-06-09 17:43:21 +03:00
Alexander Medvednikov
45f16a2640 all: coroutines (part 1) 2023-05-27 23:33:46 +02:00
Felipe Pena
38a155ac81
cgen: make comptime call works with or-block (#18215) 2023-05-21 15:22:40 +02:00
yuyi
2bb24ee739
fmt: implement comments inside sumtype declaration (#18189) 2023-05-18 11:22:26 +02:00
yuyi
e1b8617c94
ast, cgen: fix generic closures with different generic types (fix #17829) (#17834) 2023-03-31 18:08:42 +03:00
Felipe Pena
b71c131678
cgen: fix map with comp-time reflection, improve comptime var handling (#17603) 2023-03-14 13:49:29 +02:00
ChAoS_UnItY
ae6a48c0e3
all: rename it to index in array inits (#17543) 2023-03-08 20:51:45 +01:00
Felipe Pena
2879c5110c
cgen, check, parser: implement first-class option type (#17017) 2023-02-18 11:45:01 +02:00
ChAoS_UnItY
404a9aa442
v: forbid function parameter names, shadowing imported module names (#17210) 2023-02-08 20:37:04 +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
Delyan Angelov
1cad788779
checker: add error for type Alias = map[string]Alias (fix #17008) (#17015) 2023-01-18 01:34:43 +02:00
yuyi
64558df764
vlib: move the mysql/sqlite/pg/mssql modules under vlib/db (#16820) 2023-01-13 17:02:32 +02:00