Validate that dict keys are unique during parse

This commit is contained in:
Emery Hemingway 2022-10-29 01:06:32 -05:00
parent 270e13b27b
commit d0af002b4a
1 changed files with 6 additions and 2 deletions

View File

@ -54,8 +54,12 @@ proc parsePreserves*(text: string): Preserve[void] {.gcsafe.} =
var prs = Value(kind: pkDictionary)
for i in countDown(stack.high.pred, 0, 2):
if stack[i].pos < capture[0].si: break
prs[move stack[i].value] = stack[i.succ].value
stack.shrink prs.dict.len*2
var
val = stack.pop.value
key = stack.pop.value
for j in 0..prs.dict.high:
validate(prs.dict[j].key != key)
prs[key] = val
pushStack prs
Preserves.Set <- Preserves.Set: