Skip to content

test(phel): mark nil-safe parse-* as documented divergence#16

Merged
Chemaclass merged 1 commit into
mainfrom
phel/nil-safe-parse-divergences
May 29, 2026
Merged

test(phel): mark nil-safe parse-* as documented divergence#16
Chemaclass merged 1 commit into
mainfrom
phel/nil-safe-parse-divergences

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

Summary

Phel's parse-long, parse-double, parse-boolean, and parse-uuid are intentionally nil-safe: they return nil for non-string (or otherwise unparseable) input instead of throwing, so they can be chained in when / if-let without guarding. This is a documented design choice in Phel core:

"Each returns nil on invalid input instead of throwing, so callers can chain them in when/if-let without guarding against exceptions."

The exceptions test blocks currently assert p/thrown? for these inputs, which fails under Phel.

Change

Add a :phel branch to each affected exceptions block asserting nil-return instead of p/thrown?, with a comment documenting the divergence. Purely additive: every other dialect falls through to its existing :lpy / :cljs / :default branch, and Clojure's reader simply skips the unknown :phel feature.

Affected files:

  • parse_long.cljc
  • parse_double.cljc
  • parse_boolean.cljc
  • parse_uuid.cljc

Context

Part of getting the phel-lang ↔ clojure-test-suite run green (phel-lang#2223). This is the "intentional divergence" bucket; genuine Phel bugs are fixed on the phel-lang side instead.

Phel's parse-long / parse-double / parse-boolean / parse-uuid intentionally
return nil for non-string (or unparseable) input instead of throwing, so they
chain in when/if-let without guarding. Add :phel branches to the exception
blocks asserting nil-return instead of p/thrown?, documenting the difference.
Other dialects are unaffected (they fall through to their existing branches).
@Chemaclass Chemaclass merged commit 76fe261 into main May 29, 2026
4 checks passed
@Chemaclass Chemaclass deleted the phel/nil-safe-parse-divergences branch May 29, 2026 12:52
Chemaclass added a commit that referenced this pull request May 29, 2026
Phel's reader resolves :phel (else :default). Add :phel reader-conditional
branches documenting where Phel deliberately diverges from JVM Clojure on
bad-shape / edge input, so the suite is green under Phel without masking
behavior. Builds on #16 (parse-*) and #18 (string_test); covers the
remaining core_test divergences:

- nil-safe / structural returns where Clojure throws (key/val, realized?,
  < <= > >=, min-key/min/max, compare collections, peek/last/ffirst/fnext,
  empty?/not-empty, shuffle/sort-by/case/merge/update/remove/take-nth/map/
  conj/set/select-keys/reverse/keys/vals, nth/nthnext/take/drop/count/
  contains?/partial, keyword/symbol/intern); transients unguarded.
- odd?/even? operate on any number (no integer check) -> kept lenient.
- numeric tower (Bucket B): no auto bigint-promote/overflow in * + - and
  int/long/float/double/byte/rem/quot/mod; numerator/denominator int->n/1.

Suite green under Phel: 5477/5477. Related to phel-lang#2223.
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