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

Another non-exhaustive case in generated layout code #421

Closed
MatthewDaggitt opened this issue Apr 7, 2022 · 2 comments
Closed

Another non-exhaustive case in generated layout code #421

MatthewDaggitt opened this issue Apr 7, 2022 · 2 comments
Labels
layout Concerning layout (keywords)

Comments

@MatthewDaggitt
Copy link

MatthewDaggitt commented Apr 7, 2022

If you have a layout stop keyword but no corresponding layout keyword, you get a crash with a pattern match failure the same error as reported in #144.

For example if we have

....
layout "let";
layout stop "in";
....

and we write

spec : Prop
spec = forall x in d . true

gives

gen/hs/Vehicle/External/Layout.hs:(170,35)-(171,55): Non-exhaustive patterns in case

The offending generated code is:

  closingToken :: Position -> Block -> Token
  closingToken pos = sToken pos . \case
    Implicit (LayoutDelimiters _ _ (Just sy)) _ _ -> sy

which appears to have no case for Nothing.

Forgive me for not providing a full minimal example. Cutting down the grammar would be a lot of work. Hopefully this should be enough to diagnose the problem. If not then I can put in the time.

@MatthewDaggitt MatthewDaggitt changed the title Another non-exhaustive case in layout code Another non-exhaustive case in generated layout code Apr 7, 2022
@andreasabel andreasabel added the layout Concerning layout (keywords) label Apr 9, 2022
@andreasabel
Copy link
Member

andreasabel commented Apr 9, 2022

I can't reproduce this with 2.9.4 without more information, unfortunately. [Are you on 2.9.4?]

In 2.9.2 and 2.9.3 I can reproduce something like this with this grammar

layout "let";
layout stop "in";
layout toplevel;

Prg. P ::= [S] ;
separator S ";" ;

In.  S ::= "forall" Integer "in" Integer ;
Let. S ::= "let" "{" [S] "}" "in" Integer ;

and this input:

forall 4 in 3 

Error on 2.9.2:

TestIssue: LayoutIssue.hs:(166,35)-(167,55): Non-exhaustive patterns in case

Error on 2.9.3:

TestIssue: LayoutIssue.hs:(170,35)-(171,55): Non-exhaustive patterns in case

I suspect this is a 2.9.3 issue. Closing. Please reopen with some example grammar and input if this should persist in 2.9.4.

@MatthewDaggitt
Copy link
Author

Yes, we were on 2.9.3. I can confirm that 2.9.4 fixes it. Apologies I should have checked the versions first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
layout Concerning layout (keywords)
Projects
None yet
Development

No branches or pull requests

2 participants