Skip to content

Support a best approximation of if/then/else#26

Merged
jviotti merged 1 commit intomainfrom
if-then-else
Apr 16, 2026
Merged

Support a best approximation of if/then/else#26
jviotti merged 1 commit intomainfrom
if-then-else

Conversation

@jviotti
Copy link
Copy Markdown
Member

@jviotti jviotti commented Apr 16, 2026

Signed-off-by: Juan Cruz Viotti jv@jviotti.com

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 16 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="test/ir/ir_2020_12_test.cc">

<violation number="1" location="test/ir/ir_2020_12_test.cc:1541">
P2: These `allOf` branch expectations are reversed, so the test will fail against the current branch order.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread test/ir/ir_2020_12_test.cc
@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Apr 16, 2026

🤖 Augment PR Summary

Summary: This PR adds partial support for JSON Schema’s if/then/else by introducing a dedicated IR node and emitting a best-effort TypeScript type approximation.

Changes:

  • Document if/then/else as partially supported in the README.
  • Add a new IRConditional entity to the IR and include it in IREntity.
  • Extend the default IR compiler to recognize if subschemas and produce IRConditional with links to the condition/consequent/alternative subschemas.
  • Extend the TypeScript generator to emit (If & Then) | Else with an explicit comment noting that the else branch is wider than JSON Schema semantics.
  • Add new end-to-end TypeScript fixtures and IR unit tests covering object and validation-only conditionals, refs, and nesting.

Technical Notes: The emitted TypeScript intentionally cannot encode the JSON Schema “!if” constraint for the else branch, so the generated types are a conservative approximation and should be paired with runtime validation for full fidelity.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@jviotti jviotti merged commit 700dc70 into main Apr 16, 2026
12 checks passed
@jviotti jviotti deleted the if-then-else branch April 16, 2026 23:22
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