diff --git a/CHANGELOG.md b/CHANGELOG.md index e463c390b0..4bc1aabd62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ - parser: fix `;` support for `module x;` - parser: fix fixed array of option values (`_ := [10]?int{}`) (#19392) - parser: fix assigning with in another module sumtypes 2 (#19415) +- Support `;` statements, allowing for oneliners like `./v -e 'import os; println( os.ls(os.args[1])!.sorted(a > b) )' vlib/math` (#19345) - v.ast: improve Stmt.str(), showing more details about ast.Block, ast.DeferStmt, ast.ForInStmt, ast.GlobalDecl #### Compiler internals @@ -51,7 +52,6 @@ - crypto.md5: change the Digest.write return type, from `?int` to `!int` (#19311) - v.help: use os.executable() instead of @VEXE as an anchor, so `v help` will work more robustly. - toml: fix custom `to_toml` for complex structs (#19338) -- all: support `;` statements, allowing for oneliners like `./v -e 'import os; println( os.ls(os.args[1])!.sorted(a > b) )' vlib/math` (#19345) - vlib: add net.http.file, allowing for `v -e "import net.http.file; file.serve()"` (#19348) - vlib: remove functions and fields, deprecated before 2023-03-20 - toml: fix toml encoding of complex types (#19408) diff --git a/README.md b/README.md index d833f6ce33..ac65223a8c 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ ## Stability, future changes, post 1.0 freeze Despite being at an early development stage, the V language is relatively stable, and doesn't -change often. But there will bechanges before 1.0. +change often. But there will be changes before 1.0. Most changes in the syntax are handled via vfmt automatically. The V core APIs (primarily the `os` module) will also have minor changes until diff --git a/vlib/sokol/gfx/gfx_structs.c.v b/vlib/sokol/gfx/gfx_structs.c.v index b578df814c..a40d64e4f0 100644 --- a/vlib/sokol/gfx/gfx_structs.c.v +++ b/vlib/sokol/gfx/gfx_structs.c.v @@ -70,7 +70,7 @@ pub mut: pub type ColorState = C.sg_color_state -struct C.sg_pipeline_desc { +pub struct C.sg_pipeline_desc { pub mut: _start_canary u32 shader Shader @@ -97,7 +97,7 @@ struct C.sg_pipeline_info { pub type PipelineInfo = C.sg_pipeline_info -struct C.sg_pipeline { +pub struct C.sg_pipeline { pub: id u32 } @@ -304,7 +304,7 @@ pub mut: pub type Color = C.sg_color -struct C.sg_shader { +pub struct C.sg_shader { pub: id u32 } @@ -332,7 +332,7 @@ struct C.sg_pass_info { pub type PassInfo = C.sg_pass_info -struct C.sg_pass_action { +pub struct C.sg_pass_action { pub mut: _start_canary u32 colors [4]ColorAttachmentAction @@ -385,7 +385,7 @@ struct C.sg_buffer_info { pub type BufferInfo = C.sg_buffer_info -struct C.sg_buffer { +pub struct C.sg_buffer { id u32 } diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index f302d77b9d..27422f5538 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -1220,7 +1220,7 @@ fn (mut c Checker) check_or_expr(node ast.OrExpr, ret_type ast.Type, expr_return } if expr !is ast.Ident && !expr_return_type.has_flag(.option) { if expr_return_type.has_flag(.result) { - c.warn('propagating a Result like an Option is deprecated, use `foo()!` instead of `foo()?`', + c.error('propagating a Result like an Option is deprecated, use `foo()!` instead of `foo()?`', node.pos) } else { c.error('to propagate an Option, the call must also return an Option type', diff --git a/vlib/v/checker/tests/propagate_option_with_result_err.out b/vlib/v/checker/tests/propagate_option_with_result_err.out index 1652bd9912..34ce7ed6ad 100644 --- a/vlib/v/checker/tests/propagate_option_with_result_err.out +++ b/vlib/v/checker/tests/propagate_option_with_result_err.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/propagate_option_with_result_err.vv:6:7: warning: propagating a Result like an Option is deprecated, use `foo()!` instead of `foo()?` +vlib/v/checker/tests/propagate_option_with_result_err.vv:6:7: error: propagating a Result like an Option is deprecated, use `foo()!` instead of `foo()?` 4 | 5 | fn bar() ?string { 6 | foo()? diff --git a/vlib/v/gen/c/testdata/alias_interface_method_call.vv b/vlib/v/gen/c/testdata/alias_interface_method_call.vv index ec4b03a3f0..8b4954c559 100644 --- a/vlib/v/gen/c/testdata/alias_interface_method_call.vv +++ b/vlib/v/gen/c/testdata/alias_interface_method_call.vv @@ -2,8 +2,8 @@ import io { Reader } type Decoder = Reader -fn (mut d Decoder) decode(len int) ?[]u8 { +fn (mut d Decoder) decode(len int) ![]u8 { mut buf := []u8{len: len} - d.read(mut buf)? + d.read(mut buf)! return buf } diff --git a/vlib/v/gen/js/tests/option.v b/vlib/v/gen/js/tests/option.v index 24314f616b..b699275f0c 100644 --- a/vlib/v/gen/js/tests/option.v +++ b/vlib/v/gen/js/tests/option.v @@ -4,15 +4,15 @@ fn main() { try_propagation() or { println('captured: ${err}') } } -fn try_propagation() ? { - try_numbers()? +fn try_propagation() ! { + try_numbers()! } -fn try_numbers() ? { +fn try_numbers() ! { for x in 1 .. 10 { y := error_if_even(x) or { x + 1 } println('${x} rounded to ${y}') - error_if_prime(y)? + error_if_prime(y)! } } diff --git a/vlib/v/tests/option_test.v b/vlib/v/tests/option_test.v index 4620cbc6e0..6b4bbb0fc4 100644 --- a/vlib/v/tests/option_test.v +++ b/vlib/v/tests/option_test.v @@ -99,13 +99,13 @@ fn foo_str() ?string { return 'something' } -fn propagate_option(b bool) ?int { - a := err_call(b)? +fn propagate_option(b bool) !int { + a := err_call(b)! return a } -fn propagate_different_type(b bool) ?bool { - err_call(b)? +fn propagate_different_type(b bool) !bool { + err_call(b)! return true } diff --git a/vlib/v/tests/testdata/tests_returning_options_failing_test.v b/vlib/v/tests/testdata/tests_returning_options_failing_test.v index 52ab26b866..c7dd74a291 100644 --- a/vlib/v/tests/testdata/tests_returning_options_failing_test.v +++ b/vlib/v/tests/testdata/tests_returning_options_failing_test.v @@ -16,5 +16,5 @@ fn test_example() ! { fn test_example_2() { assert true assert true - example()? + example()! }