Duplicated Key in Dictionary Literal
Dictionary literals with duplicated keys will crash at runtime
- Identifier:
duplicated_key_in_dictionary_literal
- Enabled by default: Yes
- Supports autocorrection: No
- Kind: lint
- Analyzer rule: No
- Minimum Swift compiler version: 5.0.0
- Default configuration:
Key Value severity warning
Non Triggering Examples
[
1: "1",
2: "2"
]
[
"1": 1,
"2": 2
]
[
foo: "1",
bar: "2"
]
[
UUID(): "1",
UUID(): "2"
]
[
#line: "1",
#line: "2"
]
Triggering Examples
[
1: "1",
2: "2",
↓1: "one"
]
[
"1": 1,
"2": 2,
↓"2": 2
]
[
foo: "1",
bar: "2",
baz: "3",
↓foo: "4",
zaz: "5"
]
[
.one: "1",
.two: "2",
.three: "3",
↓.one: "1",
.four: "4",
.five: "5"
]