Skip to content

name collisions #8

@robx

Description

@robx

Here's some protobuf for which the elm protobuf generator results in elm code that fails to compile. For one, the MATCH enum value and the match oneof field collide. And after fixing that, I get collisions between for example the Change message type alias and the change oneof field.

I can get around this for now by renaming things (and I realize the README checklist lists oneof as unsupported), but seems worth addressing at some point? And I hope a "real-world" test case might be good to have around anyway.

syntax = "proto3";

enum ClaimType {
  MATCH = 0;
  NOMATCH = 1;
}

message Claim {
  ClaimType type = 1;
  repeated uint32 cards = 2;
}

message Event {
  message Join {
    string name = 1;
  }
  message Claimed {
    string name = 1;
    ClaimType type = 2;
    enum Result {
      CORRECT = 0;
      WRONG = 1;
      LATE = 2;
    }
    Result result = 3;
  }   
  oneof event_oneof {
    Join join = 1;
    Claimed claimed = 2;
  }
}

message Change {
  message Position {
    uint32 x = 1;
    uint32 y = 2;
  }
  message Deal {
    message Place {
      Position position = 1;
      uint32 card = 2;
    }
    repeated Place places = 1;
  }
  message Match {
    repeated Position positions = 1;
  }
  message Move {
    message MoveOne {
      Position from = 1;
      Position to = 2;
    }
    repeated MoveOne moves = 1;
  }
  oneof change_oneof {
    Deal deal = 1;
    Match match = 2;
    Move move = 3;
  }
}

message Update {
  oneof update_oneof {
    Change change = 1;
    Event event = 2;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions