Skip to content

Commit

Permalink
Emit the duplicate key as part of the error message when validating k…
Browse files Browse the repository at this point in the history
…eyed each blocks
  • Loading branch information
rafistrauss committed Mar 23, 2023
1 parent aa4d0fc commit e2ad894
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/runtime/internal/keyed_each.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function validate_each_keys(ctx, list, get_context, get_key) {
for (let i = 0; i < list.length; i++) {
const key = get_key(get_context(ctx, list, i));
if (keys.has(key)) {
throw new Error('Cannot have duplicate keys in a keyed each');
throw new Error(`Cannot have duplicate keys in a keyed each: ${key} is a duplicate`);
}
keys.add(key);
}
Expand Down
2 changes: 1 addition & 1 deletion test/runtime/samples/keyed-each-dev-unique/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export default {
dev: true
},

error: 'Cannot have duplicate keys in a keyed each'
error: 'Cannot have duplicate keys in a keyed each: 1 is a duplicate'
};

0 comments on commit e2ad894

Please sign in to comment.