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 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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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()?
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)!
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -16,5 +16,5 @@ fn test_example() ! {
|
|||
fn test_example_2() {
|
||||
assert true
|
||||
assert true
|
||||
example()?
|
||||
example()!
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue