Releases: vlang/v
Releases · vlang/v
0.4.8
V 0.4.8
28 Sep 2024
Improvements in the language
- A new
implements
keyword for explicit interface implementation - Allow multi return as fn argument (#21991)
- Define a default sumtype value (based on the first variant type) (#22039)
- Remove the obsolete .code and .msg fields of IError (#22066)
- Fix generic lambda type binding and resolution (#22083)
- Comptime support for traversing the method parameters with
$for param in method.params {
(#22229) - Show missing variants in the sum type error
- A much better and detailed unmatched fn arg error
- Add support for
@BUILD_DATE
,@BUILD_TIME
and@BUILD_TIMESTAMP
, all using v.util.get_build_time(), and overridable through SOURCE_DATE_EPOCH (#22213)
Breaking changes
- Deprecate
x.vweb
andvweb
in favor ofveb
, a faster, easier, and more stable framework.
Checker improvements/fixes
- Disallow static fn call when receiver type is unknown (#21970)
- Fix sumtype checking for voidptr variant (#21955)
- Check comptime veb.html('index.html') (#21961)
- Check if a parent generic struct has concrete types or not (#21962)
- Add support for static methods in
@FN
and@METHOD
(#21990) - Add a deprecation warning for
const ()
groups (an error after 2025-01-01) (#22019) - Improve
-d trace_checker
and error diagnostic information on compiler panics - Add error when initializing sumtype with struct as first type (#22067)
- Add infix checks for nil (#22045)
- Fix map generic fn arg passing (#22071)
- Disallow using a preexisting const name in a for loop, as either a key or value ident (#22108)
- Fix generic lambda type binding resolution (fix #22109) (#22115)
- Fix array alias (#22175)
- Restrict multiple union fields initialised at once with a nicer checker error, instead of producing an enigmatic error at cgen time (#22196)
- Fix compilation of vlib/v/slow_tests/assembly/asm_test.amd64.v (regression after dfc0c91)
- Add missing check for ref passing to non-ref (#22194)
- Check struct implements non interface type (fix #22200) (#22218)
- Suggest using the
@[_allow_multiple_values]
attribute, when declaring enums that have duplicate values (#22224) - Check for duplicate interface names in the
implements
parts of struct declarations (#22230) - Fix missing struct field type checking for type mismatch (ref vs non-ref in
mt sync.Mutex = sync.new_mutex()
) (fix #18088) (#21949) - Fix fntype var marked as auto heap (#22290)
- Check array.delete() argument mismatch (#22307)
- Add missing check for duplicated items on in expr (fix #22305) (#22308)
- Disallow infix expr on left side of assign (#22322)
- Fix array fixed return type for interface methods (#22320)
- Check arguments mismatch of array.sorted_with_compare() (fix #22327) (#22328)
- Add an error for returning an
any
value in pure V code (prevents invalid cgen) (fix #12623) (#22334) - Cleanup the checking of array method calls (#22338)
- Fix voidptr type checking (#21923)
Parser improvements
- Fix lots of parser panics, discovered through fuzzing with radamsa
- Improve the error for keyword
lock
, used as a variable name (#21937) - Improve the error message position for invalid array attr keys (#21944)
- Fix const field str() (#21998)
- Update
@include
in templates, to work with relative paths & prevent recursive calls (#21943) - Check fn call args without comma between them (related #22021) (#22075)
- parser,scanner,ast: make the scanner and parser more robust, by implementing more limits (preventing panics, discovered by fuzzing)
- Protect against too deep recursion in Expr.pos() calls
- Check too many layers embedded generic type (fix #22089) (#22091)
- Cache ident lookups for consts in ast Expr str (#22101)
- Improve Type and TypeFlag related operations (#22107)
- Fix parsing map value inside or expr (fix #12164) (#22180)
- Fix const field str() (#22192)
- Fix
.${var}
used in a template, compiled by$tmpl()
(fix #22231) (#22270) - Check enum method duplicated (fix #20924) (#22294)
Compiler internals
- scanner: guard against scanner panic, discovered by fuzzing in PR#22016
- v.builder: show the thirdparty object compilation commands too, when using
-showcc
(when the cache is empty) - builder: allow for
v -dump-defines - -check cmd/v
, which is faster, because it can skip code generation - Reduce allocations for the most common cases (#22142)
- transformer: add support for instrumenting the V compiler with
-d trace_transformer
Standard library
- encoding.base58: fix notice for slice creation (#21935)
- gg: reset ctx.mouse_d? and ctx.scroll_? at the end of each frame (fix #21945) (#21946)
- builtin: v_segmentation_fault_handler signal_number i32
- builtin: fix 'aaaa'.split('aa') (fix #21936) (#21951)
- builtin: panic on trying to grow arrays with capacity bigger than 2^31, instead of overflowing a.cap (partial fix for #21918) (#21947)
- gg: add a note that Context.new_streaming_image has to be called after Sokol's setup
- gg: add more documentation comments for gg.Config (the parameters of gg.start and gg.new_context)
- regex: fix regex.split() (fix #16876) (#21953)
- json: increase test cases before enabling sumtype decode in all json libraries (#21958)
- gg: change the type of gg.DrawImageConfig.rotate from
int
tof32
- gg: deprecate gg.DrawImageConfig.rotate, in favor of gg.DrawImageConfig.rotation, improve the documentation comments (#21963)
- x.crypto.chacha20: make Cipher struct public (fix #21967) (#21968)
- tmpl: fix an extra newline in @for; builtin: some i64 fixes
- gg: add an optional size: parameter to the .draw_pixels and .draw_pixel methods (defaults to 1.0)
- sokol: update to match upstream at c0e0563 (#21971)
- Add support for
Any
indecode_struct
,encode_struct
andto_any
(#21972) - crypto.cipher: make Stream.xor_key_stream implementers require a mutable receiver (#21974)
- sokol.audio: fix
./v -cc clang-18 -gc none simple_bytebeat.v
(the audio depends on threads) - time:
d
,c
,dd
,ddd
,dddd
pattern support for parse_format() (#22003) - flag: add optional value description to string parameters (#22024)
- flag: add custom value descriptions for bool, int, and float flags too (#22032)
- flag: fix assigning to
@[tail]
field when no fields has been matched yet inflag.parse[T]()
(#22043) - crypto: add a crypto.pbkdf2 module (#22047)
- hash: add more methods to the hash.Hash interface, to match the ones in Go (#22001)
- arrays: simplify arrays.sum and arrays.reduce (#22076)
- x.json2: support @[skip] as well (#22077)
- builtin,thirdparty: fix compilation of libgc with
-cc msvc -gc boehm
(thanks to @Ekopalypse) - stbi: change Image.data from voidptr to &u8, to reduce casts (#21977)
- time: update parse_format comment description in parse.c.v (#22104)
- vlib: add an
arrays.parallel
module, containingparallel.run/3
andparallel.amap/3
implementations (#22090) - builtin: support
-d builtin_print_use_fprintf
, make the C fn declarations stricter (#22137) - builtin: fix map.clear() not resetting map's metas and keys blocks (fix #22139) (#22140)
- builtin: fix incomplete m.clear(), allowing the map to have a duplicated entry for its first key (fix #22143) (#22144)
- builtin: fix m.clear() having different observable behavior to
m = {}
, after multiple iterations of setting keys and clearing (fix #22145) (#22146) - builtin: fix bug in .clear() caused by sizeof(u32) being 4, not 2 (fix #22148)
- flag: add support for parsing
flag.FlagParser
style flags into_struct[T]
(#22152) - flag: fix parse_bool_value() (#22160)
- flag: correct bool logic, add test (#22162)
- flag: fix parsing
flag.FlagParser
style short flags into_struct[T]
(#22172) - gg: change the type of PenConfig.thickness to f32
- builtin: remove remaining references to v_calloc in function comments (#22179)
- builtin: remove string interpolation from panic/1, to be able to use tools like cbmc in more cases (#22182)
- flag: add a relaxed parsing mode, that turn flag match errors into
no_match
entries instead (#22191) - encoding.binary: add
u16
/u32
/u64
->[]u8
conversion functions (#22193) - crypto.sha1, crypto.sha256, crypto.sha3, crypto.sha512: improve performance for non prod builds, by tagging the block_generic functions with
@[direct_array_access]
- builtin: fix string.trim() (fix #13021) (#22205)
- crypto.bcrypt: reduce runtime cost for running bcrypt_test.v, by reducing the iteration count
- crypto.scrypt: add a new
scrypt
module to vlib/crypto (#22216) - sync.stdatomic: add OpenSUSE paths for libatomic
- crypto.scrypt: add missing comment of source for test vector (#22222)
- json: allow passing an anon struct as a decode type (#22228)
- flag: fix parse_bool_value() with different order short args (fix #22176) (#22242)
- builtin: drop C in int.v (#22245)
- strconv: fix format_fl()/format_es() (fix #13210) (#22244)
- json: fix decoding of structs with embeds (#22264)
- crypto.rand: add support for convenient generation of a random big integer in the interval
[0, n)
(#22266) - json: fix json encode/decode with embed support (#22277)
- io: add a BufferedWriter and supporting methods (#22265)
- vlib: add a go like
x.benchmark
module, that estimates automatically how many iterations are needed, to get a statistically significant result (#22215) - math: document q_rsqrt
- io: make buffered_writer_test.v more robust
- builtin: enable GC lib on rv64 build (#22319)
- json: support null sum types in decode()
- crypto: ecdsa module (on top of openssl)
- bench: crypto/ecdsa.v
- math.big: fix
a + b
anda - b
, when the signs are different, add more test cases (#22330)
Web
- Check for using comptime $veb.html()/$vweb.html(), without importing veb or vweb (#21957)
- net: add net.Dialer and net.Connection interfaces, abstracting the different types of connections, already supp...
weekly.2024.39
releases: weekly.2024.39
weekly.2024.37
releases: weekly.2024.37
weekly.2024.36
releases: weekly.2024.36
weekly.2024.35
releases: weekly.2024.35
weekly.2024.34
releases: weekly.2024.34
weekly.2024.33
releases: weekly.2024.33
weekly.2024.32
releases: weekly.2024.32
weekly.2024.31
releases: weekly.2024.31
0.4.7
V 0.4.7
26 Jul 2024
Improvements in the language
- Add support for
-d ident=value
and retrieval in code via$d('ident', <default value>)
-warn-about-allocs
for debugging allocations when using manual memory management@[freed]
attribute for assign statements (for the above mode)- Implement
&&=
and||=
operators (#21678) - Improve C var args interop, allow for
fn f(some int, ...) {
(#21812) - A new flag
-n
for skipping notes (similar to-w
for skipping warnings) - Cross compilation to FreeBSD
Breaking changes
none
Checker improvements/fixes
- Fix unknown fixed array size for
const n = int(sizeof(u64)); _ = [n]int{}
(fix #21544) (#21548) - Fix checking of default field initialisations, that are part of unions of structs tagged with
@[noinit]
(#21587) - Disallow sum type with
Result
variants (#21620) - Add error for
field map
(i.e. a plain untyped map), used inside a struct (#21625) - Fix missing concrete type checking on a generic type specifier (#21614)
- Fix missing option and result wrong type return type definition (#21626)
- Turn warnings for private fields into errors (#21296)
- Support nested labeled for statements (#21658)
- Fix the return type of overloaded operators, defined on aliases of primitive types (fix #21654) (#21663)
- Fix match expr with auto promote number (#21696)
- Fix sorting compare fn with mut reference parameter (fix #21662) (#21706)
- Fix
$if x {
condition, usingconst x = $d('ident', false)
(fix #21709) (#21713) - Fix generic variable resolution on generic func return assignment (#21712)
- Fix result call or_block with multi-statements (fix #21504) (#21717)
- Allow
\uxxxxx
in raw strings (#21724) - Limit recursion in Checker.ensure_type_exists/2 to 40 levels (it is usually 4 or less) (#21734)
- Add error for
field [$d('x', 2)]int = [1, 2]!
(#21741) - Fix nested if expr method call (#21773)
- Fix generic inference in if expressions used in assignments (#21781)
- Disallow nil in non-nil arrays and vice versa (#21786)
- Check expr evaluated but not used (fix #21436) (#21816)
- Fix wrong receiver generic resolution with embed types (#21833)
- Check mismatch of fn call mut argument (fix #21857) (#21873)
- Fix global fixed array key resolution when it is a constant ident (#21900)
- Improve checks for embed in anon struct (#21877)
- Fix builtin fn var resolving (#21899)
- Fix spawn when calling undefined function (#21906)
- Require enum values to be declared, before using them in other enum values (#21913)
- Check enum field value duplicate (#21920)
- Allow embed of type alias anon struct (#21928)
Parser improvements
- Register selective import aliases as used (#21613)
- Allow multiple flag values in enum.from() for flag enums (fix #21569) (#21615)
- Disallow duplicate operator overload (#21675)
- Support
[$d('s', 4)]int{}
, move resolving to method onComptimeCall
(#21701) - Support
$d()
in fixed size arraystruct
fields (#21731) - Suggest using type alias when defining methods on non-local types (#21803)
- Sugggest map initialization with the correct syntax (#21817)
- Fix parameter collision for generated
@[flag]
enum methods, with modules namedflag
(#21844) - Fix high order generic fn resolution (#21871)
- Fix recognition of
mod.Enum.val
inside fn args (#21908)
Compiler internals
- tools,cgen,pref: add
-coverage
support +vcover
tool (#21154) - v.utils: allow to set the names of the compared items, when diffing strings (#21650)
- v.pref: fix regression of command flags not working, when there is a subfolder, named after the command, in the current working folder (#21647)
- transformer: handle
enum_variant = some_const + 10
(fix #21777) (#21779) - v.builder: print the suggestion for using
v xyz
instead ofv xyz.v
just once (#21801) - v.builder: improve the C compilation output on cgen errors (#21885)
- v.scanner: use table lookups for very frequently done character checks (#21931)
- markused: mark explicitly all used array and map methods with
-skip-unused
(fix #21907) (#21914)
Standard library
- builtin,v: reduce overhead and memory usage for very frequently called methods (#21540)
- builtin: reduce allocations in s.index_kmp/1 and s.replace/2 (#21561)
- os: remove mut declarions for unchanged vars in
os_nix.c.v
(#21564) - os: make minior improvement to C function semantics and related code (#21565)
- builtin: simplify splint_nth methods (#21563)
- toml: fix
@[toml: ]
, support@[skip]
(#21571) - builtin: update
last_index_u8
, deprecateindex_u8_last
string methods, make consistent withlast_index
(#21604) - builtin: implement a JS version of
string.split_any
(#21612) - crypto: add a
crypto.sha3
hash and extended output functions (#21664) - crypto.sha3: remove unnecessary return at the end of the write function (#21669)
- builtin: fix string.find_between(), when not found end string return '' (#21670)
- builtin: add string.camel_to_snake/0 and string.snake_to_camel/0 methods (#21679)
- cgen,x.json2: fix generic map decoding (#21704)
- encoding.base32: fix warning of implicit clone of array, by using an explicit unsafe block (#21728)
- vlib: simplify byte character conditions by using methods like is_capital, is_lower, is_letter etc (#21725)
- gg: add Context.draw_cubic_bezier_recursive/2 and Context.draw_cubic_bezier_recursive_scalar/9 (#21749)
- ci: fix deprecations_consts.out (the warning for math.max_i8 is now an error; it was deprecated since 2023-12-31)
- math: add divide_truncated/2, divide_euclid/2, divide_floored/2 and modulo_truncated/2, modulo_euclid/2, modulo_floored/2 (#21759)
- math: avoid unused calculations for math.modulo_floored/2 and math.modulo_euclid/2
- crypto.blowfish: apply
@[direct_array_access]
to very commonly used functions (#21771) - encoding.binary: little_endian_f32_at
- arrays: add arrays.chunk_while/2, where
arrays.chunk_while([0,9,2,2,3,2],fn(x int,y int)bool{return x<=y})==[[0,9],[2,2,3],[2]]
- sokol: reduce _SGL_DEFAULT_MAX_VERTICES back to 1<<17 (1<<22 in 811ac12, leads to ~140MB of memory usage for gg/minimal.v, instead of just ~38MB)
- vrepl: fix os.input() (#21811)
- Improve consistency and behavior regarding explicit mutability (#21566)
- builtin: add
pub fn arguments() []string {
; makeos.args
use it, remove edge case in cgen (#21852) - builtin: support
-d use_bundled_libgc
to make it easier to debug/upgrade reliably libgc cloned from ivmai/bdwgc (#21869) - time: increase http_header_string performance (#21894)
- builtin: add s.trim_space_left/0 and s.trim_space_right/0 methods (#21903)
- strconv,math.bits: eliminate bounds checking in commonly used routines
- arrays: fix arrays.fold, when the
init
value in the call, is an array (#21921) - string: fix leak in replace_once
Web
- net.http: change default http.Server listening address to :9009, to avoid conflicts with tools, that start their own http servers on 8080 like bytehound (#21570)
- net.urllib: update parse host to allow for better error handling (#21602)
- net.html: quick workaround for a cgen problem for
const x = int(0x80000000)
- net.http: implement http.download_file_with_progress/2, saving each chunk, as it is received, without growing the memory usage (#21633)
- veb: update import name in docs (#21668)
- Add
m3u8
MIME typeapplication/vnd.apple.mpegurl
for multimedia playlists (#21688) - veb.auth: use constant time comparision in compare_password_with_hash (#21693)
- net.http: correct
Response.status()
method comment, to indicate returning of aStatus
enum field, instead of struct (#21735) - net: fix TcpConn.peer_ip/0 to only return the ip address, without the port number (#21831)
- Add mime type
text/x-vlang
, for.v
and.vsh
file extensions (#21851) - net.conv: add conv.reverse_bytes_u64/u32/u16 (#21917)
ORM
- orm: fix subquery without where expr (#21598)
- orm: ilike for case insensitive text search
- orm: update readme with more specifics (#21697)
Database drivers
Native backend
C backend
- Fix printing of floating point values in asserts (#21538)
- Fix array fixed initialization on struct from call (#21568)
- Put the
Interface(unsafe{nil})
change for now behind -experimental (#21593) - Fix indexexpr with orexpr (fix #21591) (#21592)
- Fix generic struct init when it is a reference &T (fix #21594) (#21596)
- Fix generated code for handling fn call with result/option return on match conditional (#21608)
- Fix missing call to a function returning option, when called inside a print (fix #21616) (#21623)
- Support a
-d no_bool
option, for cgen compatibility with the C23 language standard (sincebool
is a builtin type and a keyword in it) (#21637) - Fix or expr with non option fn call return (fix #21660) (#21661)
- Generate pragmas for gcc-14, to make it more relaxed by default. Support
-no-relaxed-gcc14
for turning them off. (#21680) - Fix spawn code generated when calling conditional function (fix #19352) (#21681)
- Fix comptime generic arg resolution (allow several different struct fields in generic functions using comptime) (fix #18110) (#21682)
- Fix dumping array of reference (#21694)
- Implement g.trace_last_lines/2 to help debugging cgen problems
- Support inc cond for c style for loop with alias types (#21708)
- Fix fn call with mut reference args (fix #21265) (#21719)
- Fix auto dereference mut variable in if expr (fix #21309) (#21720)
- Fix smartcasting a reference to a sumtype value (#21730)
- Fix assert checking fn option ret with
none
(#21726) - Fix generics map with the reference argument (#21737)
- Fix shortcircuiting of infix and/or expressions (#21740)
- Simplify in infix_expr_and_or_op() (#21745)
- Fix reference variable str() method call (#21753)
- Fix scope command when
$dbg
breakpoint is on or-expr (fix #21772) (#...