diff options
| author | William Roe <git@wjlr.org.uk> | 2022-07-28 13:56:14 +0100 |
|---|---|---|
| committer | William Roe <git@wjlr.org.uk> | 2022-07-28 13:56:14 +0100 |
| commit | d913155972cb4ca4b080e176cd2e51614caca9c7 (patch) | |
| tree | 7723a22907a88a844be36750a9eaf36ff992b164 /core/encoding/json | |
| parent | 4af8a6458047787dd4b743198f20dd262f3e0592 (diff) | |
Fix bug unmarshalling JSON with assertions disabled
When asserts are disabled, code within the assert isn't run. Having
expect_token within an assert means that the state of the Parser is
mutated when asserts are run, but not when they aren't.
There's already a wrapper procedure for this pattern, which I have
reused here.
Diffstat (limited to 'core/encoding/json')
| -rw-r--r-- | core/encoding/json/unmarshal.odin | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/encoding/json/unmarshal.odin b/core/encoding/json/unmarshal.odin index 2ff268a21..97d2421d4 100644 --- a/core/encoding/json/unmarshal.odin +++ b/core/encoding/json/unmarshal.odin @@ -325,7 +325,7 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm UNSUPPORTED_TYPE := Unsupported_Type_Error{v.id, p.curr_token} if end_token == .Close_Brace { - assert(expect_token(p, .Open_Brace) == nil) + unmarshal_expect_token(p, .Open_Brace) } v := v @@ -473,7 +473,7 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm } if end_token == .Close_Brace { - assert(expect_token(p, .Close_Brace) == nil) + unmarshal_expect_token(p, .Close_Brace) } return } |