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

impure doesn't work in function assignment #1283

Open
ipromise2324 opened this issue Oct 16, 2024 · 3 comments
Open

impure doesn't work in function assignment #1283

ipromise2324 opened this issue Oct 16, 2024 · 3 comments

Comments

@ipromise2324
Copy link

ipromise2324 commented Oct 16, 2024

Background

@alan8901014 and I recently experimented with implementing polymorphism in FunC, using a ternary operation to determine which function to execute. However, we encountered a peculiar issue: even though we marked both sum() and mul() as impure, if the return value of a function is not used, any errors inside the function fail to throw as expected.

This doesn't make much sense because with the impure modifier, the function should throw an error even if its return value isn't used.

Description

Here’s the relevant functions:

description

In the main program:

image

When the return value is used (as in the op::with_dump case), the error is thrown correctly. However, in the op::without_dump case, since the return value is not utilized, the error does not throw, even though the function is marked as impure. You can refer to this test case, where theoretically it should throw an error, but its status is success.

This behavior is puzzling because, theoretically, impure functions should trigger the error regardless of whether their return value is used. We conducted additional tests, such as directly calling the function without using the return value, and in those cases, the error was thrown successfully. You can refer to the image below. When directly calling sum() and mul(), the error is successfully thrown regardless of whether the return value is used.

image

Result

image

Is this a bug, or is there something we haven't considered?!
You can refer to the complete test in this repo.
Thank you!

Environments

@ton/blueprint": "^0.24.0

Hardware Info

MacOS (Macbook M1 pro 2021) built-in SSD.

P.S. a318ed30-1848-4cd3-b8f3-3522c3259d5e

@EmelyanenkoK
Copy link
Member

EmelyanenkoK commented Nov 9, 2024

Seems like indeed assignment of the function through ternary operators leads to ignoring impure flag. We will check, thanks

@ipromise2324
Copy link
Author

Since like indeed assignment of the function through ternary operators leads to ignoring impure flag. We will check, thanks

Thanks for checking! I'd appreciate any further updates on this issue.

@EmelyanenkoK
Copy link
Member

@ipromise2324 Please contact @ton_bugs_bot on telegram (you can check authenticity here https://github.com/ton-blockchain/bug-bounty)

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

No branches or pull requests

2 participants