fix: parse union type annotations on tag variables#230
Conversation
|
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 39 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #230 +/- ##
=======================================
Coverage 99.95% 99.95%
=======================================
Files 34 34
Lines 4270 4270
Branches 793 793
=======================================
Hits 4268 4268
Misses 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
df8ebc1 to
3538b79
Compare
3538b79 to
93850d2
Compare
|
Closed: this change is unsound. |
| is overloaded as the TS union separator and the tag-body-parameters delimiter, so — unlike < — it must not be made type-aware: a typed tag variable can be followed by |params| (<tag/v: T|a,b|>), and a union type annotation must be parenthesized (A | B). Records the decision at the site so the parenthesization requirement is not re-filed as a bug (see the closed union-type PR #230).
Problem
A union type annotation on a tag variable fails to parse:
The
|prematurely terminates the tag variable atvalue: string, and the trailing| null = nullcascades intoEOF reached while parsing expression. This blocks the two most common TS unions (T | null,T | undefined). The equivalent already works for generics (Array<string>) and intersections (A & B), and a parenthesized union(string | null)also works — only the bare union|was broken.Fix
shouldTerminateConciseTagVar/shouldTerminateHtmlTagVartreatedCODE.PIPEas an unconditional terminator, whileCODE.OPEN_ANGLE_BRACKETreturns!expression.inType(so<only terminates outside a type) and&is absent entirely. Make|mirror<:return !expression.inType. This only changes behavior inside a type annotation — outside a type,!inTypeis stilltrue, so|terminates exactly as before.Tests
New fixture
tag-var-type-unioncovering bare unions in both concise and HTML tag-var forms (string | null,A | B | C,number | undefined) — each captures the full union astagVar.valuewith the initializer kept separate. Full suite passes with no existing snapshot changes;tscclean.This is the root-cause fix for the union-type-annotation issue tracked in the marko repo (where it surfaces as the
EOF reached while parsing expressioncascade on<let/d: string | null = null>).