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

Add language support for use statement #249

Closed
Tracked by #203
Wodann opened this issue Jul 25, 2020 · 2 comments · Fixed by #290
Closed
Tracked by #203

Add language support for use statement #249

Wodann opened this issue Jul 25, 2020 · 2 comments · Fixed by #290
Assignees
Labels
exp: intermediate Achievable by experienced contributors, or with some guidance pri: intermediate An issue resulting in non-critical functionality loss and no significant effect on usability type: feat New feature or request
Milestone

Comments

@Wodann
Copy link
Collaborator

Wodann commented Jul 25, 2020

Similar to Rust, we want to be able to use functions, constants and types from other modules. However, our keywords and implementation differ slightly. For more information, see #248.

Given a folder structure:

  • mod.mun
  • foo.mun
  • bar.mun

file: mod.mun

pub use foo::Foo; // Re-export a child's definition

struct Baz;

file: foo.mun

use package::{bar::Bar, Baz};
// Illegal: A statement with the same name was already imported (Even though both use statements are equivalent)
use super::Baz; 

pub(super) struct Foo {
    baz: Baz, // Can use private definitions from any of its ancestors
}

// Illegal: cannot leak a definition with smaller scope
// (i.e. [private] < pub(super) < pub(package) < pub)
pub foo_from_bar(bar: Bar) -> Foo {
    bar.0
}

file: bar.mun

use package::Foo;

pub(package) Bar(Foo);
@Wodann Wodann added type: feat New feature or request pri: intermediate An issue resulting in non-critical functionality loss and no significant effect on usability exp: intermediate Achievable by experienced contributors, or with some guidance labels Jul 25, 2020
@Wodann Wodann mentioned this issue Jul 25, 2020
4 tasks
@Wodann Wodann added this to the Mun v0.3.0 milestone Jul 25, 2020
@baszalmstra
Copy link
Collaborator

A lot of work has already been done on the HIR side in #283 to support resolution of paths between different files. And what a file exposes.

Next steps on the HIR side are:

  • Implement use statement in the parser
  • Implement resolving of all use statements and storing them in the PackageDef.

Finally we need a way to generate multiple assemblies and a way to reference one from another.

@baszalmstra
Copy link
Collaborator

I've started work on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp: intermediate Achievable by experienced contributors, or with some guidance pri: intermediate An issue resulting in non-critical functionality loss and no significant effect on usability type: feat New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants