Resolve reserved directive keywords colliding with property names - #44
Merged
Conversation
The printer needs to know which names collide with a directive keyword so it can put the @ escape back. Keeping the sets in one place also documents the collision surface in a single readable spot.
Every block decided what a line was from its first word alone, so a command property named description, validate, handler or concurrency was a parse error, and an event property named tag or an enumeration value named validate was swallowed with no diagnostic at all. Where shape decides, shape now wins: the bare directives take no operand, so a line with property shape is a property. 'description String' declares a property; 'description "..."' is still the directive, and 'validate csharp' still opens a code block. Where shape cannot decide - 'authorize X', 'produces X', 'tag X', a mapping target, an enumeration value - the '@' escape that ProjectionParser already accepted is now accepted everywhere, so '@tag TagType' declares the property. The two collisions that changed meaning in silence now warn: 'tag TagType' says it declares a static tag rather than a property, and a bare 'validate' in an enumeration says it opens an empty validate block rather than declaring a value. Both keep the meaning they have always had.
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.
Added
@escape for names that collide with a directive keyword.@tag TagTypedeclares a property calledtag,@authorize AuthorizationCodea property calledauthorize,@validatean enumeration value calledvalidate, and@key = xa projection mapping ontokey. The escape already existed in projections and now works for property lines, property mappings, enumeration values and projectionfrommappings everywhere. (Reserved directive keywords collide with property names with no escape syntax #27)Fixed
description,validate,handlerorconcurrencyno longer fails to compile. Those directives take no operand, so a line with property shape is now read as a property;description "..."andvalidate csharpkeep their directive meaning. (Reserved directive keywords collide with property names with no escape syntax #27)tag TagTypein an event body no longer silently becomes a static tag and drops the property — it still declares the tag, but the compiler now warns that the line does not declare what it looks like and points at the@tagescape. (Reserved directive keywords collide with property names with no escape syntax #27)validatein an enumeration concept no longer silently becomes an empty validate block that swallows the value — it still opens the block, but the compiler now warns and points at the@validateescape. (Reserved directive keywords collide with property names with no escape syntax #27)