Skip to content

Commit

Permalink
Fix MapMembers grammar and update test
Browse files Browse the repository at this point in the history
smithy-lang#1533 incorrectly changed
MapMembers grammar to make both MapKey and MapValue optional together,
when they are optional separately. This PR fixes the MapMembers grammar
to allow MapKey and MapValue to be optional separately, and updates a
test case to reflect that.
  • Loading branch information
milesziemer committed Dec 13, 2022
1 parent 3dbec6d commit a3b2615
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/source-2.0/spec/idl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ string support defined in :rfc:`7405`.
ElidedListMember :%s"$member"
ExplicitListMember :%s"member" *`SP` ":" *`SP` `ShapeId`
MapStatement :%s"map" `SP` `Identifier` [`Mixins`] *`WS` `MapMembers`
MapMembers :"{" *`WS` [`MapKey` `WS` `MapValue`] *`WS` "}"
MapMembers :"{" *`WS` [`MapKey` / `MapValue` / (`MapKey` `WS` `MapValue`)] *`WS` "}"
MapKey :`TraitStatements` (`ElidedMapKey` / `ExplicitMapKey`)
MapValue :`TraitStatements` (`ElidedMapValue` / `ExplicitMapValue`)
ElidedMapKey :%s"$key"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ map MixedMap {
value: String
}

map MixedMapRedefineValue {
key: String
value: String
}

service MixedService {}

resource MixedResource {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@
"target": "smithy.example#MixinMap"
}]
},
"smithy.example#MixedMapRedefineValue": {
"type": "map",
"value": {
"target": "smithy.api#String"
},
"mixins": [{
"target": "smithy.example#MixinMap"
}]
},
"smithy.example#MixinService": {
"type": "service",
"traits": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ map MixinMap {

map MixedMap with [MixinMap] {}

map MixedMapRedefineValue with [MixinMap] {
value: String
}

@mixin
service MixinService {}

Expand Down

0 comments on commit a3b2615

Please sign in to comment.