-
-
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.
autofree: fix argument freeing for json.encode and json.encode_pretty…
… calls (#22781)
- Loading branch information
Showing
4 changed files
with
35 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
string _arg_expr_json_encode_pretty | ||
string_free(&_arg_expr_json_encode_pretty_ | ||
string _arg_expr_json_encode_ | ||
string d = (_arg_expr_json_encode_ | ||
string_free(&d); // autofreed var main 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,16 @@ | ||
// vtest vflags: -autofree | ||
import json | ||
|
||
struct Foo { | ||
foo int | ||
} | ||
|
||
fn main() { | ||
mut a := { | ||
'foo': 123 | ||
} | ||
println(json.encode_pretty(a)) | ||
d := json.encode(a) | ||
dump(d) | ||
println(json.decode(Foo, d)!) | ||
} |