Skip to content

Conversation

@da-woods
Copy link
Contributor

  • Arguments passed by value don't add deduce as "const".
  • const T with const int now evaluates T as int
  • If we've deduced the type of two arguments "the same except that one is const" then that's not considered compatible (and we use the more restricted const type).

Fixes #6294

* Arguments passed by value don't add deduce as "const".
* `const T` with `const int` now evaluates `T` as `int`
* If we've deduced the type of two arguments "the same
  except that one is const" then that's not considered
  compatible (and we use the more restricted const type).

Fixes cython#6294
@da-woods da-woods added this to the 3.3 milestone Oct 19, 2025
@da-woods da-woods added the C++ label Oct 19, 2025
@da-woods
Copy link
Contributor Author

I've tagged this as 3.3 just to avoid the temptation to hold up 3.2 for it.

Copy link
Contributor

@scoder scoder left a comment

Choose a reason for hiding this comment

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

Instead of adding an option is_value_type and passing that through all the methods, we could have a second method deduce_template_params_for_value_type() that calls deduce_template_type() by default and can be overwritten separately.

Which do you find better?

@da-woods
Copy link
Contributor Author

I mildly prefer the version I have here - I think if we added a new call to deduce_template_type() the user should be considering whether its a value type and having the parameter there in the function arguments makes that more obvious - a separate function is more easily overlooked.

However - either version would work so it's not something I feel particularly strongly about if you'd rather change it.


I think this should be left to 3.3 though - a lot of the C++ template stuff can be a bit fragile so it's probably a bit risky to merge now. Although obviously I'd be happy to have it reviewed and ready to go for when that's safely branched off.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Unable to deduce type parameters for fused type

2 participants