Skip to content

Allow 'then error' without a reason - #48

Open
woksin wants to merge 3 commits into
mainfrom
feat/unnamed-specification-error
Open

Allow 'then error' without a reason#48
woksin wants to merge 3 commits into
mainfrom
feat/unnamed-specification-error

Conversation

@woksin

@woksin woksin commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Changed

woksin added 3 commits July 29, 2026 11:59
'then error' required a string, so a scenario that only asserts that an
operation was rejected had to write 'then error ""'. Most rejection scenarios
are that shape - the reason lives in the specification's name, not in the
assertion - and an empty string reads as a reason left blank rather than one
never stated.

The message becomes optional and the name becomes nullable, so the two cases
stay distinguishable: null is "rejected, reason unspecified here", empty
string is still an empty message.
@woksin woksin added the minor New features, non-breaking additions label Jul 29, 2026
@woksin

woksin commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Reviewer notes — left open for a call on the design, not merged, since it is a language decision.

Answering the two questions raised in #46:

May a bare then error and a then error "…" appear in the same specification? Yes, as implemented. They are independent assertions in a list that was already zero-or-more, and there is no reading under which mixing them is ambiguous — one says "rejected, reason unspecified here", the other "rejected with this message". Forbidding it would need a rule to justify it, and I could not find one.

Does the printer round-trip a bare then error unchanged? Yes, and there is a spec asserting it. SpecificationErrorSyntax.Name became string? specifically so the printer can tell the two apart — null prints as then error, "" still prints as then error "". Collapsing them onto one representation would have made generated documents un-diffable, which is the requirement the issue calls out.

Scope. The regex change is ^then\s+error(?:\s+"…")?$, so every existing document parses exactly as before. The only breaking surface is SpecificationErrorSyntax.Name becoming nullable — a consumer that dereferences it now needs a null check. Labelled minor on the basis that the nullability annotation change does not break compilation for consumers; say the word if you would rather it were major.

Verificationdotnet build Debug and Release both 0 errors / 0 warnings (Release treats warnings as errors); dotnet test 585 passing, 0 failing. Debug carries one pre-existing IDE0305 warning in for_ScreenplayWriter/when_inspecting_assembly_visibility.cs that predates this branch and is untouched here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features, non-breaking additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant