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

use and import in a class or record definition results in a syntax error #26484

Open
e-kayrakli opened this issue Jan 7, 2025 · 1 comment
Open

Comments

@e-kayrakli
Copy link
Contributor

We can use or import modules in function scope. Trying to do that in a class or record scope, I am getting a syntax error. I think we should be able to do that but that's not a strong preference for me, at all. However, emitting a syntax error for attempting to do so feels wrong and we should provide a more helpful error message.

record R {
  use IO;
}

You can swap record with class, and use with import. The behavior is the same.

@bradcray
Copy link
Member

bradcray commented Jan 8, 2025

This seems useful to me as well, as a way of making an external module's symbols available to all the primary methods on a record/class, or to use its symbols to define the fields. At least, I can't think of a reason we wouldn't / shouldn't support it.

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