ArgParser: backtick the Default<FieldName> member reference - #611
Merged
Conversation
Same class of bug as the record-construction fix, at a different site. [<ArgumentDefaultFunction>] makes the generator concatenate "Default" with the field's name and emit the result as an identifier -- twice, once to set the default and once to render it into help text. A field whose name needs backticks forces the member to be declared with them, and the reconstruction dropped them, so the generated file did not parse. The concatenation cuts both ways and the fix accounts for both: a field named ``mod`` needs backticks itself, but the member `Defaultmod` does not, and is still emitted bare. isValidBareRecordLabel/backtickRecordLabel are renamed to isValidBareIdent/backtickIdent, since they now serve a member name as well as a record label. The probe deliberately stays in the record-label position for every caller: it is the tightest one available, admitting exactly one identifier and nothing else. A probe in the position this new caller emits into would be far weaker -- `Owner.Defaultspace name ()` parses happily as an application, and would report success for a name which is nothing of the sort. Test first, observed failing: ConsumePlugin gained a record whose default-function fields have awkward names, and the build broke with `AwkwardDefaultFunctionName.Defaultspace in name()` before the fix. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same class of bug as the record-construction fix in #604, at a different site.
[<ArgumentDefaultFunction>]makes the generator concatenateDefaultwith the field's name and emit the result as an identifier — twice, once to set the default and once to render it into help text. A field whose name needs backticks forces the member to be declared with them too, and the reconstruction dropped them, so the generated file did not parse:The concatenation cuts both ways, and the fix accounts for both directions: a field named
modneeds backticks itself, but the memberDefaultmoddoes not, and is still emitted bare. Both are covered by tests.isValidBareRecordLabel/backtickRecordLabelare renamed toisValidBareIdent/backtickIdent, since they now serve a member name as well as a record label. The probe deliberately stays in the record-label position for every caller, which is worth knowing about: that is the tightest position available, admitting exactly one identifier and nothing else. A probe in the position this new caller emits into would be far weaker —Owner.Defaultspace name ()parses perfectly happily as an application ofOwner.Defaultspacetoname, and would report success for a name which is nothing of the sort. Being tighter than a caller needs only over-backticks, which is always safe.Test first, observed failing:
ConsumePlugingainedAwkwardDefaultFunctionName, and the build broke exactly as above before the fix. Runtime test covers both the defaulted and the user-supplied path.Suite green (1105 / 164 / 3).
🤖 Generated with Claude Code