Skip to content

Conversation

xdBronch
Copy link
Contributor

@xdBronch xdBronch commented Apr 11, 2025

this needs more (any) testing but just throwing it up for now, its quite possibly not too good! but i think the results can be pretty desirable.
closes #2052

@@ -5600,6 +5600,13 @@ fn addReferencedTypes(
},

.ip_index, .compile_error => {},
.either => {}, // TODO
.either => |either| {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this feels too easy to work...

Copy link
Member

Choose a reason for hiding this comment

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

Maybe because it's just that simple. A test case would be need however.

This logic has since been moved here.

@@ -107,8 +107,8 @@ test "struct init" {

test "decl literal on generic type" {
try testDefinition(
\\fn Box(comptime T: type) type {
\\ return <tdef>struct</tdef> {
\\fn <tdef>Box</tdef>(comptime T: type) type {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this change desirable here?

Copy link
Member

Choose a reason for hiding this comment

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

I'm mostly indifferent to this change. But if we are going to change this then we should at least remain consistent:

const <tdef>Foo</tdef> = struct {};
var <>foo = Foo{};
const Foo = <def>struct</def> {};
var foo = <>Foo{};

Either both go to Foo or both go to struct.

This will also need to handle cases like these where it needs to fall back to the old behavior:

const s = (struct { alpha: u32 }){ .alpha = 5 };
const Foo = (struct {});
var foo = Foo{};

try testDefinition(
\\const <tdef>A</tdef> = struct {};
\\const <tdef>B</tdef> = struct {};
\\fn fo<>o(_: A) B {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this fails, need to update the tests to work with array_of_DefinitionLink

@xdBronch xdBronch marked this pull request as draft April 11, 2025 04:29
@Techatrix
Copy link
Member

This PR has gotten out of date so I am closing this for now. Feel free to rebase and open a new PR if there's still interest.

@Techatrix Techatrix closed this Jul 24, 2025
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.

better typeDefiniton on functions
2 participants