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

bug: Dangling domain identifier #1814

Open
KyleleeSea opened this issue Jul 2, 2024 · 0 comments
Open

bug: Dangling domain identifier #1814

KyleleeSea opened this issue Jul 2, 2024 · 0 comments

Comments

@KyleleeSea
Copy link
Contributor

KyleleeSea commented Jul 2, 2024

Describe the bug
With the new Lezer parser, in domain there is ambiguity when a subtype statement follows a constructor or function statement that does not have a named return type.

Screenshot 2024-07-02 at 2 17 37 PM

This is because we ignore newlines and after the return type identifier, there is an optional return name identifier for functions and constructors. When a subtype statement follows, the next identifier could be either the start of a subtype or the end of a function/constructor output type.

It is ambiguous to Lezer which is the correct case and it ends up accepting it as the return name for the function/constructor, causing a parse error.

To Reproduce
Go to domain
Type:

type A
type B        
function f(A arg) -> B
A <: B

Observe error on last line

Notes
We've tried the following to fix this:

  1. Adding ambiguity markers so Lezer uses GLR. This did not have any effect although we tried many different combinations of where ambiguity markers went.
  2. Looking into insertsemi to see if the insertedsemi on newline would hint to Lezer that the new identifier belonged to a new statement after a newline. For some reason, this insertedsemi would be placed on newline, but removed and moved to following the ambiguous identifier once the identifier has been typed. This seems to do with acceptToken in Codemirror library.
  3. Making domain newline sensitive. This was decided to be not worth it because it leads to requiring newlines, having to make special rules about newlines at the beginning of programs, and potential extraneous edge cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants