Skip to content

Signature fields named nil, true or false keep their names - #248

Merged
deepfates merged 1 commit into
mainfrom
claude/field-named-nil
Sep 28, 2026
Merged

deepfates merged 1 commit into
mainfrom
claude/field-named-nil

Conversation

@deepfates

Copy link
Copy Markdown
Owner

The property test "signature dump/load round-trips the serialized contract" failed on #247's CI with the generated spec "nil: string -> a: string": the loaded signature's input was :"" where it was nil. This happens on main and on v0.5.0 as well. The property hit it by chance.

The cause: a field name written as text becomes its existing atom, and "nil" became the atom nil. Field.dump/1 then wrote to_string(nil), which is "".

A name written as nil, true or false now keeps its text, so the field is named "nil" and saves and loads as "nil". A field given the atom nil, true or false as its name is refused with ArgumentError, since those atoms are values, not names.

Two tests in test/property_invariants_test.exs:

  • fields named nil, true and false keep their names through dump, JSON and load;
  • Field.new(nil, :input) raises.

With main's field.ex, both fail (5 properties, 2 tests, 2 failures). With this change: 5 properties, 35 tests, 0 failures across the property, repeated-names, signature-optimizer and doc-contract tests. mix compile --warnings-as-errors is clean.

@deepfates
deepfates merged commit 7784e3c into main Sep 28, 2026
10 checks passed
@deepfates
deepfates deleted the claude/field-named-nil branch September 28, 2026 14: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