Skip to content

Conversation

@vshakitskiy
Copy link
Contributor

Closes #5227.

@giacomocavalieri
Copy link
Member

Hello! Would you mind rebasing on main to resolve the conflicts?

@vshakitskiy vshakitskiy force-pushed the go-to-definition-for-type-aliases branch 2 times, most recently from 0630dd9 to d0a133f Compare January 12, 2026 10:57
@vshakitskiy vshakitskiy force-pushed the go-to-definition-for-type-aliases branch 2 times, most recently from daa2053 to cb47031 Compare January 12, 2026 11:06
@vshakitskiy
Copy link
Contributor Author

Done!

Copy link
Member

@giacomocavalieri giacomocavalieri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! I've left a comment and a small stylistic note

@giacomocavalieri
Copy link
Member

This is looking great! I've left a final round of small comments

@vshakitskiy vshakitskiy force-pushed the go-to-definition-for-type-aliases branch from 8dea2f8 to 007b7c7 Compare January 12, 2026 12:33
@vshakitskiy
Copy link
Contributor Author

Thanks for the reviews! Should be looking good now. I need to do more documentation comments in my future commits.

Copy link
Member

@giacomocavalieri giacomocavalieri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, still will still need to be reviewed by Louis before it can be merged!

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I've left some notes inline

TestProject::for_source(code),
find_position_of("Two").nth_occurrence(2)
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have a tests for these please:

  • An alias that points to a custom type

  • Aliases within more complex type expressions:

    fn wibble() -> List(Two)
                        ^^^
    fn wibble() -> #(One(Two), Int)
                         ^^^
  • Aliases used in custom type definitions

  • Aliases used in type alias definitions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I am not sure what does "alias used in custom type/type alias definition" mean. Do you mean:

// Alias in custom type definition
type One(a) {
  One(a)
}

type Two = Int

fn wibble() -> One(Two) {
//                 ^^^
  todo
}
// Alias in type alias definition
type One(a) = List(a)

type Two = Int

fn wibble() -> One(Two) {
//                 ^^^
  todo
}

module: Some(module_name.clone()),
span,
})
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm confused by this branch. Why is that all the importable modules are traversed when the type alias is referred to without a module qualifier?

Won't that return the definition location for the first type with the same name, regardless of where it was defined? Not sure I'm understanding it correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood the importable_modules, it contains all modules in the project, for some reason I thought it is slightly different thing 🙏. This is not the logic I intended to have here.

I should probably pass module's imports to definition_location, then in None branch find which import brought in this type name, and then look up in that specific module.

@lpil lpil marked this pull request as draft January 12, 2026 15:14
@lpil
Copy link
Member

lpil commented Feb 7, 2026

When you are ready for a review please un-draft this PR and tag me for a review. Thank you!

@vshakitskiy
Copy link
Contributor Author

@lpil Sorry for keeping the PR drafted🙏. I was waiting for the response regardless of the test cases. Quoting the question again:

I am not sure what does "alias used in custom type/type alias definition". Do you mean:

// Alias in custom type definition
type One(a) {
  One(a)
}

type Two = Int

fn wibble() -> One(Two) {
//                 ^^^
  todo
}
// Alias in type alias definition
type One(a) = List(a)

type Two = Int

fn wibble() -> One(Two) {
//                 ^^^
  todo
}

I was more confused about type alias definition part. Am I thinking in the right way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LSP: support Go to Type Definition for type aliases

3 participants