Skip to content

Conversation

scristobal
Copy link
Contributor

@scristobal scristobal commented May 12, 2025

From the CHANGELOG:

  • The function signature helper now displays original function definition
    generic names when arguments are unbound. For example, in this code:

    pub fn wibble(x: something, y: fn() -> something, z: anything) { Nil }
    
    pub fn main() {
        wibble( )
            // ↑
    }

    will show a signature help

    wibble(something, fn() -> something, anything)

    instead of

    wibble(a, fn() -> a, b) -> Nil

resolves #4570

@lpil
Copy link
Member

lpil commented Jun 16, 2025

Hello! Is this ready for a review?

@lpil
Copy link
Member

lpil commented Jul 16, 2025

Hi @scristobal, are you still working on this?

@scristobal scristobal force-pushed the issue-4570-minimal branch 4 times, most recently from 08e9b98 to d51a6c4 Compare July 20, 2025 18:03
@scristobal
Copy link
Contributor Author

Hi @scristobal, are you still working on this?

Ups, sorry busy weeks at work lately. I think this should be there.

Thanks for your patience!

@scristobal scristobal marked this pull request as ready for review July 20, 2025 18:10
@lpil
Copy link
Member

lpil commented Jul 21, 2025

Not at all, thank you!

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.

Lovely, thank you. I've left some little questions inline.

_ = self.type_variables.insert(id, local_alias.clone());
}

pub fn map_new_variable(&mut self, old_id: u64, new_id: u64) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you document what this does please? 🙏

I was a bit confused by the word "map" as in my mind that means a function like list.map. Is there a name that someone like me with less context would find extra clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With pleasure!

renamed the function to reassign_type_variable_alias which is much more explicit, also added a small comment on top describing what it does. Hope it helps!

let v = self.new_unbound_var();
let _ = ids.insert(*id, v.clone());
let new_id = self.previous_uid();
self.names.map_new_variable(*id, new_id);
Copy link
Member

Choose a reason for hiding this comment

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

This looks good. What was the situation in which it wouldn't work without this change? A comment explaining it would be helpful for future readers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely, great feedback!

I added a comment explaining why this is necessary, also changed new_id name which was confusing, coming from a previous id... 🤔

I hope it is more clear now!

@scristobal scristobal force-pushed the issue-4570-minimal branch from d51a6c4 to 04bce9b Compare July 26, 2025 08:01
@scristobal scristobal requested a review from lpil July 26, 2025 08:53
Copy link
Member

@GearsDatapacks GearsDatapacks left a comment

Choose a reason for hiding this comment

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

This looks good! One small change seems odd to me, asked inline


----- Signature help -----
guard(Bool, a, fn() -> a) -> Float
guard(Bool, b, fn() -> b) -> Float
Copy link
Member

Choose a reason for hiding this comment

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

Do you know why this has changed? The generics are named a, so this should print a, not b here.

@Copilot Copilot AI review requested due to automatic review settings August 29, 2025 19:14
Copilot

This comment was marked as spam.

// Preserve any user-provided name from the original generic variable
// for the new unbound variable. This ensures error messages and type
// displays continue to use meaningful names (e.g., "something") rather
// than auto-generated ones (e.g., "a", "b").
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this mean that the previous variable no longer has the name? Instead of both of them having that name due to their pointing to the same type.

Maybe this is the cause of the behaviour @GearsDatapacks pointed out above.

@lpil
Copy link
Member

lpil commented Aug 31, 2025

Do you know why there's some AI review thing in this PR? It doesn't look like it's enabled for this repo so I don't understand why it's here.

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.

Use new type printer for signature help
3 participants