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

Exceptions #365

Merged
merged 19 commits into from
Aug 27, 2019
Merged

Exceptions #365

merged 19 commits into from
Aug 27, 2019

Conversation

samuelgruetter
Copy link
Collaborator

@samuelgruetter samuelgruetter commented Aug 24, 2019

This PR might contain everything needed to get desugaring of :-.

I say might because I have not yet tested it as thoroughly as I think it should be tested, but I'm blocked on #364.

Still to be tested:

  • test patterns on the LHS of :-
  • test printer for :- on expression level, should it also print the desugared term?
  • test for generic Result<T> instead of NatOutcome where T is hardcoded to Nat
  • test error messages and their positions for :- on expression level

use PartiallyResolveTypeForMemberSelection to get Type instead of `?` in
error message
Coco says "LL1 warning in UnaryExpression: lbrace is start of several alternatives"
is start of several alternatives"

The problem was that I made the `var pattern` part preceding `:=` or
`:|` optional (from Coco's point of view), because it's optional for
`:-`, and enforced presence of `var pattern` using `SemErr`.
However, since `:|` can be preceded by attributes, which start by
`{`, and set display starts by `{` as well, one look-ahead is not
enough any more when parsing an expression, as we have to determine
whether we should parse a `{:myAttribute} :|` (which will later be
rejected by a SemErr saying that `:|` needs an LHS) or a `{1, 2, 3}`.

The idea is to leave the `LetExpr` rule untouched wrt master,
and write a separate rule for `LetOrFailExpr` for `:-`, which turns
out to introduce less code duplication than feared, and is simpler
to read too.

But now we have to disambiguate between `LetExpr` and `LetOrFailExpr`,
which would require lookahead until we encounter `:=`, `:|`, or `:-`,
which we would have to implement manually without being able to
reuse Coco-generated code for rules, which does not sound like a
good thing to try.
This reverts commit b6f9aa1.
except the two warnings which are already present on master:

Coco/R (Apr 19, 2011)
checking
  OldSemi deletable
  OptGenericInstantiation deletable
parser + scanner generated
0 errors detected
@richardlford
Copy link
Collaborator

Can you point me to some documentation on this new feature? I'm going to try to update the reference manual and need to collect documentation of features since it was last edited.

@RustanLeino
Copy link
Collaborator

Here is the current description of the feature: dafny-lang/rfcs#1

@RustanLeino
Copy link
Collaborator

You can also find some of this information as comments in Resolver.cs:

  • For the statement form of :-, see lines 10092..10095 as well as 10117..10120.
  • For the expression form of :-, see lines 12339 and 12340.

@RustanLeino RustanLeino merged commit df56c17 into dafny-lang:master Aug 27, 2019
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.

3 participants