Skip to content

Commit

Permalink
Merge branch 'smithy-lang:main' into trait-code-generation
Browse files Browse the repository at this point in the history
  • Loading branch information
hpmellema authored Jan 25, 2024
2 parents 4609bd0 + c7a179e commit 83eb527
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ private void parseEnumShape(ShapeId id, SourceLocation location, AbstractShapeBu
tokenizer.expect(IdlToken.LBRACE);
tokenizer.next();
tokenizer.skipWs();
Set<String> parsedMemberNames = new HashSet<>();

while (tokenizer.getCurrentToken() != IdlToken.EOF && tokenizer.getCurrentToken() != IdlToken.RBRACE) {
List<IdlTraitParser.Result> memberTraits = IdlTraitParser
Expand All @@ -676,6 +677,10 @@ private void parseEnumShape(ShapeId id, SourceLocation location, AbstractShapeBu
tokenizer.expect(IdlToken.IDENTIFIER);
String memberName = internString(tokenizer.getCurrentTokenLexeme());

if (!parsedMemberNames.add(memberName)) {
throw syntax(id, "Found conflicting member name, `" + memberName + "`");
}

MemberShape.Builder memberBuilder = MemberShape.builder()
.id(id.withMember(memberName))
.source(memberLocation)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// smithy.example#Foo: Syntax error at line 8, column 5: Found conflicting member name, `BAR`
$version: "2.0"

namespace smithy.example

enum Foo {
BAR = "bar"
BAR = "bar"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// smithy.example#Foo: Syntax error at line 8, column 5: Found conflicting member name, `BAR`
$version: "2.0"

namespace smithy.example

intEnum Foo {
BAR = 10
BAR = 10
}

0 comments on commit 83eb527

Please sign in to comment.