Releases: vlang/v
Releases · vlang/v
weekly.2024.05
releases: weekly.2024.05
weekly.2024.04
releases: weekly.2024.04
weekly.2024.03
releases: weekly.2024.03
0.4.4
V 0.4.4
9 January 2024
Improvements in the language
- Implement
@[aligned]
and@[aligned:8]
attributes for structs and unions (#19915) - Update attributes to use new syntax
- Update remaining deprecated attr syntax (#19908)
- Support
$if T is $array_dynamic {
and$if T is $array_fixed {
in addition to$if T is $array {
(#19882) - Prepare for making
-W impure-v
the default (#19940) - Assigning
0
to reference fields now requires unsafe blocks (fix #14911) (#19955) - Unwrap const() blocks
- Implement $for comptime T.variants (#20193)
- Add
r
andR
switches for repeating in string interpolation,'${"abc":3r}'
== 'abcabcabc' (#20197) - Comptime refactor and cleanup (#20196)
- Allow comptime-for to iterate over comptime variables, add
$string
comptime type, cleanup (#20233) - Unwrap an option value automatically, inside
if o != none {
(#20275) - Complete support for smartcasting to a comptime variable type (#20270)
- Improve comptime var checking with
is
operator and smartcasting (#20315)
Breaking changes
none
Checker improvements/fixes
- Disallow
$for i in struct.values
and$for i in enum.fields
(#19845) - Parser, checker: fix var scope in lambda(fix #19860) (#19871)
- Change the warning
more than 1000 possibilities in match range
to a notice (#19862) - Fix inability to use multiple
import some modname as _
in the same .v file (fix #19899) (#19900) - Disallow casting strings to pointers outside
unsafe
(#19977) - Disallow directly indexing sumtype and interface, when using as parameters(fix #19811) (#19982)
- Fix loop on aggregates of arrays (in match branches) of sumtypes (fix #18548) (#19988)
- Disallow indexing mut struct, passed as a fn parameter (#19992)
- Enhance err msg for unknown types for comptime
$for
(#20057) - Fix .clone()/.move() with shared maps (#20083)
- Fix generics method call with struct short syntax args(fix #20030) (#20100)
- Fix unwrap, when generic structs are used as arguments, in uncalled methods (fix #20132) (#20135)
- Fix generic fn with generic fn call returning generic map (fix #20106) (#20150)
- Cast sumtype to its variant generic type (#20166)
- Refactor
string
toenum
error check, handleEnumName(string_variable)
too (#20210) - Fix generic array method call with multi-types (#20237)
- Remove unnecessary struct ref field initialization checks and notifications at map initializing(fix #20245) (#20251)
- Add a notice, for accessing by key, map values, that contain pointers (to use unsafe or an
or {}
block) (#20266) - Fix mismatch checking when a function returns sumtype as an argument (fix #19325) (#20264)
- Fix and cleanup uninitialized checks for array initialisers with
len:
(fix #20272) (#20279) - Give an error for
.free()
method calls, when used on fixed arrays (#20320) - Fix type mismatch checking for assignments with generics (fix #20298) (#20327)
- Fix too strict checking with generics in assignment type mismatch (fix #20335) (#20346)
- Disallow
string
tovoidptr
cast entirely (#20351) - Fix generic method calls with multi generic types (fix #20330) (#20360)
Parser improvements
- parser: fix parsing comments after new attribute syntax
- parser: fix failures found with fuzzing (#19873)
- parser: deprecate old attribute syntax & update remaining (missed) attributes (#19879)
- parser: fix infix expr handling with cast on left side of << operator (#19985)
- ast: fix generic structs with multiple levels of generic embedding (#20042)
- parser: implement thread returns result and multi_returns (fix #19281) (#20194)
- parser: fix formatting struct decl with comments (#20207)
- parser: fix formatting enum and interface decl with comments (#20216)
- parser: fix fn call with newline opening brace (fix #20258) (#20267)
- parser: fix parse_vet_file() with vfmt off/on flag (#20273)
Compiler internals
- scanner: implement support for UTF-32 escape codes in string literals (#19911)
- scanner: add new_silent_scanner/0, Scanner.prepare_for_new_text/1, make .ident_char/0, .ident_string/0 and .text_scan/0 public (#20045)
- pref: support VNORUN=1, to enable running of tests, vsh files etc (i.e. just compile them, for debugging later)
- scanner: fix backslashes followed directly by newline in string literals (fix #20291) (#20296)
- scanner: fix escape character handling in character/rune literals (fix #20301) (#20304)
- pref: disable the -macosx_version_min clang flag by default (#20297)
- builder: remove passing
-fno-strict-aliasing
, for-prod
to gcc/icc (#20368) - markused: add
-skip-unused
for programs thatimport x.vweb
too (do not skip unused routing methods)
Standard library
- json: fix recursive pointer encoding (#19840)
- os,picohttpparser,sokol,strconv: prepare for making
-W impure-v
the default (#19846) - os: add fast path to mkdir_all, when the given folder already exists (#19869)
- os: ignore empty path segments in
join_path
(#19877) - os: fix bootstrapping for OpenBSD
- x.json2: replace deprecated type byte with u8 in the tests (#19909)
- vlib: change byte to u8 (#19930)
- sync: add a FreeBSD specific version of vlib/sync/sync_default.c.v (#19962)
- datatypes: add push_many for doubly and singly linked list + add insert_many for heap (#19975)
- datatypes: make
Direction
pub and fix and add tests forpush_many
(#19983) - gg: fn (data voidptr, e &Event) for events, allows methods
- vlib: add a
compress.szip
module, deprecate theszip
one after 2023-12-31 (#20003) - os: create the folder described by
XDG_CACHE_HOME
, if it is non empty, and it does not exist yet, when callingos.cache_dir()
(#20046) - vlib: use the builtin flush functions, instead of the C. ones (#20108)
- crypto: add blake2s and blake2b hashes (#20149)
- os: fix
mv_by_cp
for directories (#20154) - os: update mv fns, improve performance, add params struct to control overwrite behavior (#20156)
- gg: fix overlapping slices in
draw_slice_filled()
(#20182) - json: fix option sumtype handling (#20186)
- builtin: add
@[direct_array_access]
to js string trim_right method (#20222) - json2: add encoder support for
time.Time
(#20228) - json2: fix encoding of 💀🐈 etc emojis (fix #20243) (#20247)
- json2: make public the generic function
map_from/1
(#20294) - json2: optimise encoding to be faster than cJSON with -prod (#20052)
- json2: support sumtype encoding in a more robust way (#20093)
- json2: strict module (#17927)
- crypto: fix notices/errors for
v -N test vlib/crypto
- crypto: add blake3 hash (#20319)
- sokol: fix compiling gg and other graphical examples on OpenBSD (#20333)
- csv: Add a sequential reader too (suitable for very large .csv files, it does not read everything at once) (#20140)
Web
- net.mbedtls: use
char
andusize
types for describing more precisely the C API of mbedtls (#19837) - vweb: add the mime type for .toml files (#19875)
- net.openssl: use actual C values for the SSLError enum (#19945)
- vweb: .html('custom_template.html')
- vweb: add an optional parameter to the .redirect/2 method, to be able to set the http code for the redirects (#20082)
- x.vweb: fix large payload (#20155)
- x.vweb: reimplement csrf module (#20160)
- net: make net.fionbio and net.msg_nosignal constants public in net_windows.c.v (#20183)
- net.http: remove unused
read_set_cookies
function (#20187) - os, net.http.file: add a folder listing to the http static file server, started by file.serve/1 (#20192)
- websocket: enable using an already existing connection (from vweb or another http server) (#20103)
- x.vweb: fix fsanitize-address test for SSE, improve documentation on the usage of
takeover_conn
(#20249) - net.http: support
-d no_vschannel
on windows, to fix long waits, while connecting on some systems (#20265) - x.vweb: fix
$vweb.html()
integration in cgen for the newerx.vweb
module (fix #20204) - net: support only ip and ip6 in net.tcp_listener (#20336)
- x.vweb.assets: reimplement assets module for x.vweb (#20280)
- x.vweb.sse: reimplement SSE module for x.vweb (#20203)
- js.dom: add querySelector[All] and NodeList (#20240)
ORM
- orm: fix code generation for an option time.Time field (#20031)
- orm: fix the generated SQL for the "not equal" operator (#20321)
Database drivers
- db.mysql: add support for the FreeBSD name of the mariadb client library (#20039)
- db.pg: fix using postgresql on windows, improve instructions for installing it (#20053)
- db.mysql: add ability to prepare and execute statements separately (#20146)
- db.pg: fix compilation error with the msvc compiler on windows, and add readme (#20326)
Native backend
C backend
- Fix generic fn returning fixed array (#19885)
- Fix arrays alias built-in methods call(fix #19896) (#19910)
- Fix generic array initialization (fix #19903) (#19916)
- Fix option sumtype auto deref (#19919)
- Ast, checker, cgen: fix interface embeded methods call(fix #16496) (#19936)
- Fix ref and deref when an interface is used as a function parameter (fix #19947) (#19966)
- Fix auto str for interface struct member which implements str method (#19970)
- Fix generics call with interface arg (fix #19976) (#20002)
- Fix lambda initialization on option struct field (fix #19474) (#19995)
- Fix live mode on windows (#20041)
- Fix the static from_string method of Enum across mods(fix #20050) (#20068)
- Fix
@[if xyz?] fn init() {}
, add tests (#20096) - Fix assignment to the elements of an array of fixed arrays (#20133)
- Fix mutable comptimeselector usage (fix #20027) (#20134)
- Fix generics chans select (#20159)
- Fix string interp with zero characters (fix #20199) (#20200)
- Fix interface eq method with option and ref (fix #19441) (#20201)
- Fix infix expr in method of mut receiver variable (#20225)
- Fix cgen for thread wrappers, when spawning fns with with anon-fn arra...
weekly.2024.01.test2
releases: weekly.2024.01.test2
weekly.2023.52
releases: weekly.2023.52
weekly.2023.51
releases: weekly.2023.51
weekly.2023.50
releases: weekly.2023.50
weekly.2023.48
releases: weekly.2023.48
0.4.3
V 0.4.3
11 November 2023
Improvements in the language
- A new
encoding.xml
module with parser, validation, entity encoding, unit tests (#19708) - Better couroutines support (IO, networking)
- Allocations in vweb apps reduced by 80%
- Implement
@VCURRENTHASH
to replaceC.V_CURRENT_COMMIT_HASH
(#19514) - int => i64 on 64 bit, i32 on 32 bit (start of the transition)
- Fix new int type promotion rules and cleanup native gen() (#19535)
Breaking changes
Request.cookies
map has been deprecated. Replaced withRequest.cookie()
andRequest.add_cookie()
.- Stricter rules for C types (they always have to be declared now)
Checker improvements/fixes
- Turn the option/result split warning into an error
- Turn propagation warning into an error (finishes the option/result split)
- Fix fn call with option call argument in autofree mode (#19515)
- Bring back pascal case check for aliases
- C.xx = C.yy aliases
- Allow casted integeral types in match ranges (#19572)
- Warn about byte deprecation, when used as a fn parameter (#19629)
- Allow size of fixed array to be integral casts (#19663)
- Fix generic array append (#19658)
- Check error of implementing other module private interface (fix #19620) (#19688)
- Extend byte deprecation warning to array init types (#19671)
- Extend byte deprecation warnings to return types (#19668)
- Fix negative cap, len checks in array init (#19694)
- Turn warning for var and param module name duplicates into error (#19645)
- Fix closure in if guard, including with multi_return (#19765)
- Fix comptime enumdata value property access (#19768)
- Fix
field ?&Type
without default value (#19786) - Avoid nil assign to option var (#19746)
- Allow for a shared variable to be whole reassigned (keeping the same mutex state) (fix #15649) (#19751)
Parser improvements
- Fix assigning static method to anon fn (#19499)
- ast: fix formatting a struct declaration with a nested struct (#19592)
- Add
set_all
+clear_all
methods to[flag]
enum bitfields (#19717) - ast: reduce cost of frequently called functions by using constants (#19733)
- Warn on unused imports, even when they are declared via
import math { sin, cos }
(#19738) - ast: add missing docstrings for the public fns in vlib/v/ast/types.v (#19752)
- Give a friendly error when misusing if over $if (#19810)
- Add multiple struct attributes error for new attribute syntax
Compiler internals
- checker, builder, pref: support
-dump-defines -
to help explore all the available user and system defines for a given program (#19576) - pref,builder: add support for
-macosx-version-min 10.2
and-macosx-version-min 0
(with default of 10.7) (#19626) - pref: fix unintended file extensions in default output names, allow for
v run file.c.v
(#19745) - transformer: fix using a constant, instead of a fn parameter with the same name (fix #19766) (#19773)
- maps: add maps.merge() and maps.merge_in_place() generic utility functions (#19776)
- coroutines: only attempt to add/remove roots when GC is on.
- markused: cleanup in mark_used(), use robust index names, instead of the much more brittle integer values (#19543)
Standard library
- builtin: add an
unsafe { a.reset() }
method, for quickly setting all bytes in an array to 0 - math.fractions: use operator overloading and deprecate old functions (#19547)
- gg: fix the alignment of the bottom border of draw_rounded_rect_empty on macos and linux
- crypto.bcrypt: fix bcrypt failure for valid pass and hash (fix #19558) (#19569)
- sokol: update sokol to the latest version
- builtin: fix sizeof(C.BOOL) (windows specific) (#19589)
- math.big: fix incorrect division with negative numbers (fix #19585) (#19587)
- os: add a convenient way to ignore certain system signals (#19632)
- os: fix os.ls(folder) on windows, when a protected folder can not be opened (#19647)
- os: add a convenient way to ignore certain system signals (#19639)
- crypto.sha: fix calculating the same hash values when .sum() is called several times for sha1/256/512 (fix #19696) (#19697)
- crypto.md5: fix calculating the same hash values, when .sum() is called several times (#19703)
- os: add a new function
execute_opt
(#19723) - os: add os.page_size() (#19770)
- os: implement os.fd_is_pending/1, os.Process.pipe_read/1, os.Process.is_pending/1 (#19787)
- builtin: copy min/max integer values consts from
math
to builtin so that the entire math module doesn't have to be imported(#19809) - json2: add support for nested structs (#19579)
Web
- vweb: add mime type support for static .md files
- net.conv: add varinttou64 and u64tovarint functions, for the variable unsigned integer encoding, described in rfc9000 (for QUIC) (#19568)
- net.http: support passing on_running, on_stopped, on_closed callback functions to http.Server{}, as well as show_startup_message: false. (#19591)
- net: fix handling of spurious wake-up signals, lost when calling select() in mbedtls and openssl (continue on C.EINTR) (#19600)
- net: use conv.hton* consistently, instead of
$if tinyc { conv.hton16(port) } $else { u16(C.htons(port)) }
- net.http: support passing an HTTP proxy server in http.fetch (#19606)
- net.http: add a retry mechanism to http.fetch(), when the socket inevitably errors (#19660)
- wasm: implement inline assembly (#19686)
- net.http: increase max_redirects to 16 (#19743)
- picoev: implement raw mode (#19771)
- flag,json,net: handle C calls in .v files (part of enabling
-W impure-v
as default) (#19779) - net.http: add socks5|http(s) proxy support [Linux] (#19676)
ORM
- orm: add null handling and option fields (#19379)
- orm: make is_null/is_not_null unary ops; don't bind null in where (#19635)
Database drivers
- pg: hande C calls, move to .c.v files (#19739)
Native backend
- native: support
-no-builtin
(generate executables < 1KB Linux withv -no-builtin -b native examples/hello_world.v
) - native: use i32 instead of int
C backend
- Fix printing fixed array of options (#19479)
- Fix struct field of fixed array init (fix #19483) (#19487)
- Fix struct init with multi option fn type (#19491)
- Ast, native, cgen: add support for
$if native {}
(#19500) - Fix maps with i32 keys
- Fix for c stmt with option or result calls (#19641)
- Fix infix op when handling comptime selector (#19691)
- Fix array contains method with interface(fix #19670) (#19675)
- Reduce expense in repetitively called functions by using consts (#19732)
- Fix closure parameter judgment when var cross assign inside anon fn(fix #19734) (#19736)
- Only generate free in wrapper for spawn and not go (#19780)
- Fix g.obf_table data missing(fix #19695) (#19778)
- Fix closure variable in smartcast (#19796)
vfmt
- Remove additional line breaks after call_expr before params struct args (#19795)
- Fix map value aligment when using keys with uft8 symbols (#19689)
- Align ternary expressions in const blocks (#19721)
- Respect range index expressions in match branches (#19684)
- Respect raw strings in
$embed_file(r'/some/path')
expressions (#19753) - Fix formatting of struct field with default value and new attr syntax (#19683)
- Recognize or blocks in call args (#19690)
Tools
- all: add support for
@LOCATION
, for more convenient logging/tracing, without needing to combine@FILE
,@LINE
at runtime (#19488) - benchmark: add new methods b.record_measure/1 and b.all_recorded_measures/0 (#19561)
- ci: update c2v workflow, translate doom on macOS (#19562)
- strings: add Bulder.write_decimal/1 method (write a decimal number, without additional allocations) (#19625)
- testing: add temporary file hash to prevent accidental collisions with test file binaries (#19710)
- ci: compile VTL and VSL in their own CI job, with
VFLAGS=-no-parallel
- tools: fix windows install of an already existing module with vpm (#19761)
- tools: use
VPM_NO_INCREMENT
env var to skip dl count increment when testing vpm (#19756) - tools.vpm: improve handling of urls that end with .git (#19758)
- tools: fix resolving external dependencies in vpm, add test (#19772)
- tools: cleanup and simplify vcreate, for upcoming fixes and features (#19794)
- tools: improve error messages, add color coding and debug logging (#19781)
- tools: fix
v build-tools
, makev test
more robust (#19803) - tools: add parse_query to vpm (#19814)
- ci: add macos arm64 binary release (#19823)
- Require the presence of a
v.mod
file, to install external urls via vpm (#19825) - vcreate: fix
v init
with project names containing dashes (#19619)
Operating System support
Examples
- tests: workaround name conflict, causing false positives with msvc on windows, when both tests were executed at the same time (locked executable)