seedwing-io / seedwing-policy

A functional type system for policy inspection, audit and enforcement.
https://www.seedwing.io
Apache License 2.0
12 stars 15 forks source link

fix: add check for duplicate field names #201

Closed danbev closed 1 year ago

danbev commented 1 year ago

This commit adds a check to make sure that duplicate field names cause an error to be reported.

For example, with this commit starting the swio server will generate the following error:

$ cargo r --bin swio -- serve
     Running `target/debug/swio serve`
Error: 
    ╭─[csaf:59:3]
    │
 59 │   contact_details?: string,
    │   ────────────┬───────────  
    │               ╰───────────── Duplicate field declared. Please remove one of "contact_details"
────╯

Fixes: https://github.com/seedwing-io/seedwing-policy/issues/181

danbev commented 1 year ago

The last commit (https://github.com/seedwing-io/seedwing-policy/pull/201/commits/035829b5941fa3dcbe56b8a87b1f4bc6e27a9ff4) is mainly a suggestion for further work and will produce the following output in the playground:

playground_error

The error message itself i not very nice but that can probably be improved.

danbev commented 1 year ago

@ctron Thanks for the review!