Skip to content

Fix: AST Builder maps div to DIVIDE instead of TRUNCATED_DIVIDE#1705

Merged
JPercival merged 2 commits intomainfrom
fix/truncated-divide-operator
Mar 16, 2026
Merged

Fix: AST Builder maps div to DIVIDE instead of TRUNCATED_DIVIDE#1705
JPercival merged 2 commits intomainfrom
fix/truncated-divide-operator

Conversation

@JPercival
Copy link
Copy Markdown
Contributor

Summary

  • The CQL div operator (truncated integer division) was mapped to BinaryOperator.DIVIDE (same as /) in the AST Builder, losing the distinction between true division and truncated division.
  • Added TRUNCATED_DIVIDE to the BinaryOperator enum.
  • Fixed the existing BuilderExpressionTest assertion that incorrectly expected DIVIDE for div.

Note: This only affects the AST Builder (new pipeline). The legacy Cql2ElmVisitor already correctly emits TruncatedDivide for div.

Test plan

  • Existing BuilderExpressionTest updated to assert TRUNCATED_DIVIDE for 5 div 2
  • Test passes

🤖 Generated with Claude Code

The CQL `div` operator (truncated integer division) was mapped to
BinaryOperator.DIVIDE (same as `/`), meaning the AST lost the
distinction between `/` (true division) and `div` (truncated division).

- Add TRUNCATED_DIVIDE to BinaryOperator enum
- Map `div` to TRUNCATED_DIVIDE in Builder
- Fix existing test assertion that incorrectly expected DIVIDE for div

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

Related Issues

The following open issues may be related to this PR:

Issue Title Score Matched Terms
#1430 Correctly support CQL to FHIR (and vice versa) type mapping 10 between, instead, com, code, correctly, https, expected, java (path), src (path), main (path), org (path), cql (path), hl7 (path)
#1133 ToList is not implemented according to the spec 9.5 operator, com, code, already, https, java (path), src (path), expressions (path), main (path), expression (path), org (path), cql (path), hl7 (path), test (path)
#931 Library XML deserializer doesn't include annotations 9 instead, com, code, generated, https, maps, java (path), src (path), main (path), org (path), cql (path), test (path)
#1505 'Collapse' on at least 2 closed datetime intervals without a high value always fails 8.5 between, true, com, note, https, expected, java (path), src (path), main (path), org (path), cql (path)
#1486 Allow a custom implementation of the State Cache 7.5 com, https, maps, expected, java (path), src (path), expressions (path), main (path), expression (path), org (path), cql (path)

Tip: If this PR addresses any of these issues, please link them using Closes #NNN or Refs #NNN in the PR description.

@github-actions
Copy link
Copy Markdown

Formatting check succeeded!

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.97%. Comparing base (f33dbd0) to head (9e0e1ca).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1705   +/-   ##
=========================================
  Coverage     61.97%   61.97%           
  Complexity     3940     3940           
=========================================
  Files           210      210           
  Lines         20366    20366           
  Branches       3879     3879           
=========================================
  Hits          12621    12621           
  Misses         6138     6138           
  Partials       1607     1607           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@JPercival JPercival merged commit 7dc65a1 into main Mar 16, 2026
9 of 10 checks passed
@JPercival JPercival deleted the fix/truncated-divide-operator branch March 16, 2026 18:03
JPercival added a commit that referenced this pull request Mar 16, 2026
- properly between: PR #1704 merged
- div/truncated divide: PR #1705 merged
- chunk-tracking error: PR #1706 merged

Renamed to "Translator Issues" since these aren't "legacy" yet.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
JPercival added a commit that referenced this pull request Mar 28, 2026
- properly between: PR #1704 merged
- div/truncated divide: PR #1705 merged
- chunk-tracking error: PR #1706 merged

Renamed to "Translator Issues" since these aren't "legacy" yet.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants