mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Parse #no_nil on unions
This commit is contained in:
@@ -711,6 +711,7 @@ Union_Type :: struct {
|
|||||||
poly_params: ^Field_List,
|
poly_params: ^Field_List,
|
||||||
align: ^Expr,
|
align: ^Expr,
|
||||||
is_maybe: bool,
|
is_maybe: bool,
|
||||||
|
is_no_nil: bool,
|
||||||
where_token: tokenizer.Token,
|
where_token: tokenizer.Token,
|
||||||
where_clauses: []^Expr,
|
where_clauses: []^Expr,
|
||||||
variants: []^Expr,
|
variants: []^Expr,
|
||||||
|
|||||||
@@ -2600,6 +2600,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
|||||||
poly_params: ^ast.Field_List
|
poly_params: ^ast.Field_List
|
||||||
align: ^ast.Expr
|
align: ^ast.Expr
|
||||||
is_maybe: bool
|
is_maybe: bool
|
||||||
|
is_no_nil: bool
|
||||||
|
|
||||||
if allow_token(p, .Open_Paren) {
|
if allow_token(p, .Open_Paren) {
|
||||||
param_count: int
|
param_count: int
|
||||||
@@ -2626,6 +2627,11 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
|||||||
error(p, tag.pos, "duplicate union tag '#%s'", tag.text)
|
error(p, tag.pos, "duplicate union tag '#%s'", tag.text)
|
||||||
}
|
}
|
||||||
is_maybe = true
|
is_maybe = true
|
||||||
|
case "no_nil":
|
||||||
|
if is_no_nil {
|
||||||
|
error(p, tag.pos, "duplicate union tag '#%s'", tag.text)
|
||||||
|
}
|
||||||
|
is_no_nil = true
|
||||||
case:
|
case:
|
||||||
error(p, tag.pos, "invalid union tag '#%s", tag.text)
|
error(p, tag.pos, "invalid union tag '#%s", tag.text)
|
||||||
}
|
}
|
||||||
@@ -2669,6 +2675,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
|||||||
ut.where_token = where_token
|
ut.where_token = where_token
|
||||||
ut.where_clauses = where_clauses
|
ut.where_clauses = where_clauses
|
||||||
ut.is_maybe = is_maybe
|
ut.is_maybe = is_maybe
|
||||||
|
ut.is_no_nil = is_no_nil
|
||||||
|
|
||||||
return ut
|
return ut
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user