Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up type validation on lists #205

Merged
merged 2 commits into from
May 1, 2023
Merged

Conversation

dburgener
Copy link
Owner

#199 caused some of our type matching on lists to start to fail. First clean up the error message when this happens, which was previously a TODO, then try harder to infer the right types. As mentioned in the second commit message, this has us guess (possibly wrongly) on ambiguity. For a post-0.1 future enhancement, we should detect ambiguity and require the developer to annotate.

@dburgener dburgener force-pushed the dburgener/list_validation branch 2 times, most recently from 87aa028 to 058771a Compare May 1, 2023 20:52
If we get a list in a binding like:

```
let foo = [ bar baz qux ];
```

We don't know what types to expect when validating.  That could cause
the validation to assume the wrong type, if eg bar is both a domain and
a permission.  So we try our best, and if the list is inconsistent, we
see what types we got and try revalidating the full list against each of
those types.  If we get a match, we use that, otherwise we error.

Currently this assumes only one valid match.  It's possible that we
could have multiple valid matches.  For example:

```
resource read {}
resource write {}

let foo = [ read write ];
```

In this case, we don't know if foo is supposed to be a list of
permissions or a list of resources until we start using it.  As a future
enhancement, we should detect that there are ambiguous possibilities and
prompt the developer to annotate the binding like so:

```
let foo<perm> = [ read write ];
```

But that is future work, not part of this PR
@dburgener dburgener force-pushed the dburgener/list_validation branch from 058771a to 43a2cf6 Compare May 1, 2023 21:50
@dburgener dburgener merged commit d1c3c33 into main May 1, 2023
@dburgener dburgener deleted the dburgener/list_validation branch May 1, 2023 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants