-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v: add selector option unwrapping inside
if tree.root != none {
(#2…
- Loading branch information
Showing
10 changed files
with
113 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
vlib/v/checker/tests/assign_type_mismatch_with_generics_err.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
vlib/v/checker/tests/option_ptr_without_unwrapp_err.vv:7:13: error: cannot use `?&Node` as `Node`, it must be unwrapped first in argument 1 to `set_trace` | ||
vlib/v/checker/tests/option_ptr_without_unwrapp_err.vv:6:12: error: cannot use `?&Node` as `Node`, it must be unwrapped first in argument 1 to `set_trace` | ||
4 | | ||
5 | fn set_trace(n Node) { | ||
6 | if n.parent != none { | ||
7 | set_trace(n.parent) | ||
| ~~~~~~~~ | ||
8 | } | ||
9 | } | ||
6 | set_trace(n.parent) | ||
| ~~~~~~~~ | ||
7 | } | ||
8 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import datatypes { DoublyLinkedList } | ||
|
||
pub type LayoutBoxId = usize | ||
|
||
pub struct LayoutBox { | ||
} | ||
|
||
pub struct LayoutTree { | ||
mut: | ||
root ?LayoutBoxId | ||
boxes []LayoutBox | ||
} | ||
|
||
pub fn LayoutTree.new() LayoutTree { | ||
return LayoutTree{ | ||
root: ?LayoutBoxId(none) | ||
boxes: []LayoutBox{} | ||
} | ||
} | ||
|
||
fn test_main() { | ||
mut tree := LayoutTree.new() | ||
tree.root = 1 | ||
if tree.root != none { | ||
mut parents := DoublyLinkedList[LayoutBoxId]{} | ||
parents.push_back(tree.root) | ||
assert parents.len == 1 | ||
} else { | ||
assert false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
type SumType = int | string | ||
|
||
struct Struct { | ||
a int | ||
} | ||
|
||
struct Foo { | ||
a ?int | ||
b ?string | ||
c ?SumType | ||
d ?Struct | ||
} | ||
|
||
fn test_main() { | ||
w := Foo{ | ||
a: 123 | ||
b: 'foo' | ||
c: SumType(123) | ||
d: Struct{ | ||
a: 123 | ||
} | ||
} | ||
if w.a != none { | ||
dump(w.a) | ||
assert w.a == 123 | ||
} else { | ||
assert false | ||
} | ||
if w.b != none { | ||
dump(w.b) | ||
assert w.b == 'foo' | ||
} else { | ||
assert false | ||
} | ||
if w.c != none { | ||
dump(w.c) | ||
assert w.c is int | ||
} else { | ||
assert false | ||
} | ||
if w.d != none { | ||
dump(w.d) | ||
assert w.d.a == 123 | ||
} else { | ||
assert false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters