You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@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:
In the main program:
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.
Result
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
The text was updated successfully, but these errors were encountered:
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:
In the main program:
When the return value is used (as in the
op::with_dump
case), the error is thrown correctly. However, in theop::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.
Result
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
The text was updated successfully, but these errors were encountered: