Skip to content

json stringify: nested interfaces, llvm-type resolution, member_access dispatch#99

Merged
cs01 merged 1 commit intomainfrom
json-stringify-improvements
Mar 6, 2026
Merged

json stringify: nested interfaces, llvm-type resolution, member_access dispatch#99
cs01 merged 1 commit intomainfrom
json-stringify-improvements

Conversation

@cs01
Copy link
Owner

@cs01 cs01 commented Mar 6, 2026

json stringify: nested interfaces, llvm-type resolution, member_access dispatch

Summary

Three gaps in JSON.stringify dispatch that caused silent wrong output or compile errors:

  • Nested interface fields: emitAddFieldsToJsonObj previously loaded any non-string/non-boolean field as double, which is wrong for nested interface-typed fields (stored as i8*). Now detects nested interfaces via interfaceStructGenHasInterface and recursively builds a sub-object using csyyjson_obj_add_obj.
  • LLVM-type resolution: resolveInterfaceType only checked the symbol table by variable name. Variables populated from JSON.parse<T>() have their type in the LLVM type map (%T*) but not always in symbolTable.getInterfaceType. Now falls back to extracting the interface name from the LLVM type string, enabling JSON.stringify(cfg) where cfg = JSON.parse<Config>(str).
  • member_access dispatch: JSON.stringify(user.address) where address: Address previously fell through to an error. Now resolves the field's TS type by walking the parent interface's struct layout.

Test plan

  • json stringify nested interface fields — roundtrips Person { name, age, address: Address { street, zip } }
  • json stringify of a json parse result — parses, stringifies, re-parses Config { host, port, debug }
  • All existing json stringify/parse tests pass
  • npm run verify:quick passes (Stage 0 + Stage 1 self-hosting + full unit tests)

@cs01 cs01 force-pushed the json-stringify-improvements branch from f8b1161 to 6540f16 Compare March 6, 2026 17:32
@cs01 cs01 changed the title json stringify: fix silent fallbacks, nested interfaces, llvm-type re… json stringify: nested interfaces, llvm-type resolution, member_access dispatch Mar 6, 2026
@cs01 cs01 merged commit a396623 into main Mar 6, 2026
12 checks passed
@cs01 cs01 deleted the json-stringify-improvements branch March 6, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant