mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
checker: turn propagation warning into an error; sokol: make some structs public
This commit is contained in:
parent
a79c574cb9
commit
f8693adfa2
9 changed files with 20 additions and 20 deletions
|
@ -34,6 +34,7 @@
|
||||||
- parser: fix `;` support for `module x;`
|
- parser: fix `;` support for `module x;`
|
||||||
- parser: fix fixed array of option values (`_ := [10]?int{}`) (#19392)
|
- parser: fix fixed array of option values (`_ := [10]?int{}`) (#19392)
|
||||||
- parser: fix assigning with in another module sumtypes 2 (#19415)
|
- 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
|
- v.ast: improve Stmt.str(), showing more details about ast.Block, ast.DeferStmt, ast.ForInStmt, ast.GlobalDecl
|
||||||
|
|
||||||
#### Compiler internals
|
#### Compiler internals
|
||||||
|
@ -51,7 +52,6 @@
|
||||||
- crypto.md5: change the Digest.write return type, from `?int` to `!int` (#19311)
|
- 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.
|
- 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)
|
- 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: 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
|
- vlib: remove functions and fields, deprecated before 2023-03-20
|
||||||
- toml: fix toml encoding of complex types (#19408)
|
- toml: fix toml encoding of complex types (#19408)
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
## Stability, future changes, post 1.0 freeze
|
## Stability, future changes, post 1.0 freeze
|
||||||
|
|
||||||
Despite being at an early development stage, the V language is relatively stable, and doesn't
|
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.
|
Most changes in the syntax are handled via vfmt automatically.
|
||||||
|
|
||||||
The V core APIs (primarily the `os` module) will also have minor changes until
|
The V core APIs (primarily the `os` module) will also have minor changes until
|
||||||
|
|
|
@ -70,7 +70,7 @@ pub mut:
|
||||||
|
|
||||||
pub type ColorState = C.sg_color_state
|
pub type ColorState = C.sg_color_state
|
||||||
|
|
||||||
struct C.sg_pipeline_desc {
|
pub struct C.sg_pipeline_desc {
|
||||||
pub mut:
|
pub mut:
|
||||||
_start_canary u32
|
_start_canary u32
|
||||||
shader Shader
|
shader Shader
|
||||||
|
@ -97,7 +97,7 @@ struct C.sg_pipeline_info {
|
||||||
|
|
||||||
pub type PipelineInfo = C.sg_pipeline_info
|
pub type PipelineInfo = C.sg_pipeline_info
|
||||||
|
|
||||||
struct C.sg_pipeline {
|
pub struct C.sg_pipeline {
|
||||||
pub:
|
pub:
|
||||||
id u32
|
id u32
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ pub mut:
|
||||||
|
|
||||||
pub type Color = C.sg_color
|
pub type Color = C.sg_color
|
||||||
|
|
||||||
struct C.sg_shader {
|
pub struct C.sg_shader {
|
||||||
pub:
|
pub:
|
||||||
id u32
|
id u32
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ struct C.sg_pass_info {
|
||||||
|
|
||||||
pub type PassInfo = C.sg_pass_info
|
pub type PassInfo = C.sg_pass_info
|
||||||
|
|
||||||
struct C.sg_pass_action {
|
pub struct C.sg_pass_action {
|
||||||
pub mut:
|
pub mut:
|
||||||
_start_canary u32
|
_start_canary u32
|
||||||
colors [4]ColorAttachmentAction
|
colors [4]ColorAttachmentAction
|
||||||
|
@ -385,7 +385,7 @@ struct C.sg_buffer_info {
|
||||||
|
|
||||||
pub type BufferInfo = C.sg_buffer_info
|
pub type BufferInfo = C.sg_buffer_info
|
||||||
|
|
||||||
struct C.sg_buffer {
|
pub struct C.sg_buffer {
|
||||||
id u32
|
id u32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 !is ast.Ident && !expr_return_type.has_flag(.option) {
|
||||||
if expr_return_type.has_flag(.result) {
|
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)
|
node.pos)
|
||||||
} else {
|
} else {
|
||||||
c.error('to propagate an Option, the call must also return an Option type',
|
c.error('to propagate an Option, the call must also return an Option type',
|
||||||
|
|
|
@ -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 |
|
4 |
|
||||||
5 | fn bar() ?string {
|
5 | fn bar() ?string {
|
||||||
6 | foo()?
|
6 | foo()?
|
||||||
|
|
|
@ -2,8 +2,8 @@ import io { Reader }
|
||||||
|
|
||||||
type Decoder = 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}
|
mut buf := []u8{len: len}
|
||||||
d.read(mut buf)?
|
d.read(mut buf)!
|
||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,15 @@ fn main() {
|
||||||
try_propagation() or { println('captured: ${err}') }
|
try_propagation() or { println('captured: ${err}') }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_propagation() ? {
|
fn try_propagation() ! {
|
||||||
try_numbers()?
|
try_numbers()!
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_numbers() ? {
|
fn try_numbers() ! {
|
||||||
for x in 1 .. 10 {
|
for x in 1 .. 10 {
|
||||||
y := error_if_even(x) or { x + 1 }
|
y := error_if_even(x) or { x + 1 }
|
||||||
println('${x} rounded to ${y}')
|
println('${x} rounded to ${y}')
|
||||||
error_if_prime(y)?
|
error_if_prime(y)!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,13 +99,13 @@ fn foo_str() ?string {
|
||||||
return 'something'
|
return 'something'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn propagate_option(b bool) ?int {
|
fn propagate_option(b bool) !int {
|
||||||
a := err_call(b)?
|
a := err_call(b)!
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
fn propagate_different_type(b bool) ?bool {
|
fn propagate_different_type(b bool) !bool {
|
||||||
err_call(b)?
|
err_call(b)!
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,5 +16,5 @@ fn test_example() ! {
|
||||||
fn test_example_2() {
|
fn test_example_2() {
|
||||||
assert true
|
assert true
|
||||||
assert true
|
assert true
|
||||||
example()?
|
example()!
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue