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

Bind type(...).min and type(...).max to the operand type #1158

Closed
ggiraldez opened this issue Nov 25, 2024 · 0 comments · Fixed by #1177
Closed

Bind type(...).min and type(...).max to the operand type #1158

ggiraldez opened this issue Nov 25, 2024 · 0 comments · Fixed by #1177
Assignees

Comments

@ggiraldez
Copy link
Contributor

The type() expressions in Solidity return some information about the type argument. This information is dependent on what the argument is (see the documentation). The binding rules already bind to different built-in types depending on the argument, using special case rules and @type guarded paths in the stack graph (see the rules here).

Both for integer types and enums though, the .min and .max fields should bind to the argument type, but they are currently fixed in the built-in definitions as uint. This would be ideally expressed through generic types, but since Solidity does not support them, it's not possible to encode the desired behaviour in the built-ins. For cases like this, we need to encode the return type in the binding rules themselves. For example, binding of array's push() which returns a reference to the pushed element is implemented here.

To avoid later conflicts, this should be implemented on top of #1149.

github-merge-queue bot pushed a commit that referenced this issue Jan 23, 2025
…>.<member>` so they work with extensions (#1177)

Fixes #1158.
Fixes #1196.

Considerations:
 * ~~It's built on top of #1149~~ It's rebased on master.
 * ~~It's currently missing a test for `max`~~
* ~~I adapted an existing test, though maybe it's preferred to add a
different one?~~
* I use the same test for min and max, I think it makes sense to have
them together. I'm not so sure where to put it though. It's testing
these functions, but also in combination with `using for`, so it can
very well be moved to the `using` folder.
 
 EDITED
@github-project-automation github-project-automation bot moved this from ⏳ Todo to ✅ Done in Slang - 2024 H2 Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
2 participants