cgen: fix json decode with optional argument (fix #13943) (#13958)

This commit is contained in:
yuyi 2022-04-07 00:34:22 +08:00 committed by GitHub
parent 56e6fd01c5
commit c9dcdf6744
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 4 deletions

View file

@ -0,0 +1,21 @@
import json
import os
struct DbConfig {
foo int
}
fn test_json_decode_with_optional_arg() {
if ret := print_info() {
println(ret)
} else {
println(err)
}
assert true
}
fn print_info() ?string {
dbconf := json.decode(DbConfig, os.read_file('dbconf.json') ?) ?
println(dbconf)
return '$dbconf'
}