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

feat: add type aliases #110

Closed
7 tasks done
Wodann opened this issue Apr 1, 2020 · 6 comments · Fixed by #251
Closed
7 tasks done

feat: add type aliases #110

Wodann opened this issue Apr 1, 2020 · 6 comments · Fixed by #251
Labels
exp: intermediate Achievable by experienced contributors, or with some guidance good first issue Good for newcomers pri: low An issue with no impact to quality, performance, or functionality type: feat New feature or request

Comments

@Wodann
Copy link
Collaborator

Wodann commented Apr 1, 2020

We want to introduce type aliases, as follows:

type Typename = OtherTypeName;

In large, this change builds on existing architecture, but it will require work in several places of our stack:

  • lexer: add the type keyword (src, example)
  • parsing: add parsing of type TypeName = OtherTypeName (example#1, example#2)
  • hir: add type aliases as type definition (src)
  • tests: add test for all of the above stages

Good first issue process:

If this is your first PR, welcome 🎉 😄

@fominok
Copy link
Contributor

fominok commented May 18, 2020

Hey,
I think that this issue will make more sense if generics feature lands. Or are there any use cases in current language state?

@baszalmstra
Copy link
Collaborator

Yes there was previously a case where this was needed. But that was no longer the case so this has much lower priority.

@Wodann Wodann added pri: low An issue with no impact to quality, performance, or functionality type: feat New feature or request exp: intermediate Achievable by experienced contributors, or with some guidance labels May 22, 2020
@sinato
Copy link
Contributor

sinato commented Aug 11, 2020

I have a question about mun-lang syntax. Should type aliases be definable in a block?
For example, should Example 2 work the same as Example 1?
Example1:

type OtherTypename = i32;
type Typename = OtherTypename;
fn main() {
    let a: Typename = 10
}

Example2:

type OtherTypeName = i32;
fn main() {
    type Typename = OtherTypeName;  // <- Does mun-lang expect this?
    let a: Typename = 10;
}

@Wodann
Copy link
Collaborator Author

Wodann commented Aug 11, 2020

Yes, Rust supports this and my expectation for Mun was to mimick this.

@sinato
Copy link
Contributor

sinato commented Aug 21, 2020

@Wodann
Hi, may I create a PR to support only Example1?

rust-analyzer does not yet support Example2.

The current code in rust-analyzer just completely ignores local items and builds a Resolver instance for top-level scope.

rust-lang/rust-analyzer#1165
I think it would be better to wait a little longer for the implementation of Example 2 to reuse their consideration and implementation.

@baszalmstra
Copy link
Collaborator

Definitely! We prefer smaller increments.

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 good first issue Good for newcomers pri: low An issue with no impact to quality, performance, or functionality type: feat New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants