Skip to content

anonymous given parse error #6864

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

Closed
bishabosha opened this issue Jul 16, 2019 · 3 comments
Closed

anonymous given parse error #6864

bishabosha opened this issue Jul 16, 2019 · 3 comments

Comments

@bishabosha
Copy link
Member

bishabosha commented Jul 16, 2019

minimized code

trait Foo
trait Bar

given as Foo 
given as Bar
//    ^
//    not found: type as

trait C
trait Baz[A]

given as C
given [A] as Baz[A]
//    ^
//    an identifier expected, but '[' found

expectation

These should parse and are fixed by adding brackets to the above given, e.g. given as Foo {} or a newline in between.

@liufengyun
Copy link
Contributor

I'm not sure if this is a bug, as the following code is valid, and we need to support given params specified in a new line:

class C
class D()
  given C

@bishabosha
Copy link
Member Author

Ah, I hadn't thought of that, I found this issue through code that used to work with the previous keywords.

@nicolasstucki
Copy link
Contributor

The current new line scheme supports

given as Foo 
  given Bar

which is equivalent to

given as Foo given Bar

This is a consequence of having renamed delegate to given. Now we do not know if the next given is the start of a definition or a given parameter.

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

4 participants