-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v: define a default sumtype value (based on the first variant type) (v…
- Loading branch information
1 parent
0b8ded4
commit 243ca4c
Showing
11 changed files
with
124 additions
and
45 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
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
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,20 +1,44 @@ | ||
&Expr(ParExpr{ | ||
expr: Expr(InfixExpr{ | ||
left: unknown sum type value | ||
right: unknown sum type value | ||
left: Expr(InfixExpr{ | ||
left: unknown sum type value | ||
right: unknown sum type value | ||
}) | ||
right: Expr(InfixExpr{ | ||
left: unknown sum type value | ||
right: unknown sum type value | ||
}) | ||
}) | ||
}) | ||
&Expr(ParExpr{ | ||
expr: Expr(InfixExpr{ | ||
left: unknown sum type value | ||
right: unknown sum type value | ||
left: Expr(InfixExpr{ | ||
left: unknown sum type value | ||
right: unknown sum type value | ||
}) | ||
right: Expr(InfixExpr{ | ||
left: unknown sum type value | ||
right: unknown sum type value | ||
}) | ||
}) | ||
}) | ||
&Expr(InfixExpr{ | ||
left: unknown sum type value | ||
right: unknown sum type value | ||
left: Expr(InfixExpr{ | ||
left: unknown sum type value | ||
right: unknown sum type value | ||
}) | ||
right: Expr(InfixExpr{ | ||
left: unknown sum type value | ||
right: unknown sum type value | ||
}) | ||
}) | ||
&Expr(InfixExpr{ | ||
left: unknown sum type value | ||
right: unknown sum type value | ||
left: Expr(InfixExpr{ | ||
left: unknown sum type value | ||
right: unknown sum type value | ||
}) | ||
right: Expr(InfixExpr{ | ||
left: unknown sum type value | ||
right: unknown sum type value | ||
}) | ||
}) |
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,37 @@ | ||
type MyType = int | string | ||
type MyType2 = bool | int | string | ||
type MyType3 = string | u64 | ||
type MyType4 = ?string | bool | ||
|
||
struct Test { | ||
a MyType | ||
b MyType2 | ||
c MyType3 | ||
d MyType4 | ||
} | ||
|
||
fn test_struct() { | ||
t := Test{} | ||
assert dump(t.a) == MyType(0) | ||
assert dump(t.b) == MyType2(false) | ||
assert dump(t.c) == MyType3('') | ||
assert dump(t.d) == MyType4(?string(none)) | ||
} | ||
|
||
fn test_main() { | ||
x := MyType{} | ||
println(x) | ||
assert x == MyType(0) | ||
|
||
y := MyType2{} | ||
println(y) | ||
assert y == MyType2(false) | ||
|
||
w := MyType3{} | ||
println(w) | ||
assert w == MyType3('') | ||
|
||
z := MyType4{} | ||
println(z) | ||
assert z == MyType4(?string(none)) | ||
} |
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