← Back to Pull requests

Dates: make DateFormat parse errors compile under `--trim=safe` #64621

Closed
unknown closed this pull request without merging on Nov 04, 2026 01:53 UTC
View on GitHub
unknown unknown commented on Nov 03, 2026 16:54 UTC
Author

Why

juliac --trim=safe rejects every program that parses text with a Dates.DateFormat. That covers Date(text), DateTime(text, format), Time(text, format), and Timestamp(text). The verifier reports an unresolved string call on the parser's error path, at stdlib/Dates/src/parse.jl:104.

The "Expected directive" message prints directives[directive_index]. That is a runtime index into the format's tuple of directives, whose element types differ, so inference widens the element to a union with the abstract DatePart. The string call on it can't be resolved statically.

This came up in Durations.jl and Postgres.jl, which want trimmed programs to parse timestamps with Dates' own parser instead of carrying their own.

Change

  • The generated tryparsenext_core builds a tuple of the directives' printed forms, with one string(directives[i]) call per directive, and indexes that instead. Each call sees its directive's concrete type. The message text is unchanged, and the strings are built only on the error path.

  • test/trim/Trimmability now parses a Date and a DateTime with a DateFormat. The build fails verification without the fix.
  • Verification

  • Trim. A program with the new _test_dates() fails the verifier on 1.14.0-alpha2, with 4 errors at parse.jl:104. With the fix loaded, it builds and prints dates: 2026-03-08 2026-03-08T16:00:00.500.

  • A wider trim program. It parses Date, DateTime, and Timestamp text with default and custom formats, including tryparse and the error path. On 1.14.0-alpha2 its 10 errors at parse.jl:104 go away. The executable throws the usual message, "Unable to parse date time. Expected directive Delim(:) at char 17".

  • Dates tests. The stdlib Dates suite passes on nightly 1.15.0-DEV.97 with the fixed tryparsenext_core loaded over the stdlib's: 147 testsets and 7,732,903 tests, the same count as without it. Nightly's parse.jl is identical to master's.

  • Not run locally. I did not build Julia from source, so the test/trim Trimmability target itself has not run here.
  • Backports

    The same line is on release-1.12, release-1.13, and release-1.14. On 1.13.3, applying this change alone made Date and DateTime parsing with a DateFormat compile under --trim=safe in the same test programs.

    🤖 Generated with Claude Code

    Diff: 299 lines (+224 / -75) across 3 files Reviewer: KristofferC Review duration: 538m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 299 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.341
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #64621"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40% (MEDIUM) · Higher = larger blast radius
    40%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.8% · Safe to merge
    15.8%