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
There are a few places in the analyzer where we use expressions::expr to analyze expressions, when we should be using expressions::assignable_expr.
The name assignable_expr is not very clear, so we should consider changing that too.
The purpose of assignable_expr is to make sure expressions are in the default location of their type. The yulgen phase is then able to assume the location of a given value. If we don't do this, then we will have all sorts of undefined behavior.
How can it be fixed
Fix the following places and double check that we are using these functions correctly every where else.
contract Foo:
my_array: u256[3]
pub def bar() -> u256:
self.my_array = [1,2,3]
sum: u256 = 0
for i in self.my_array:
sum = sum + i
return sum
^ example of a feature that does not work properly at the moment
The yulgen phase expects the iterabe value to be in memory, but since we're not analyzing the expression with assignable_expr, there is no move_location attributed to it, so the array stays in storage. This results in OOG error during the execution of bar, since it attempts to access the array in memory using the very large storage pointer.
What is wrong?
There are a few places in the analyzer where we use
expressions::expr
to analyze expressions, when we should be usingexpressions::assignable_expr
.The name
assignable_expr
is not very clear, so we should consider changing that too.The purpose of
assignable_expr
is to make sure expressions are in the default location of their type. The yulgen phase is then able to assume the location of a given value. If we don't do this, then we will have all sorts of undefined behavior.How can it be fixed
fe/crates/analyzer/src/traversal/expressions.rs
Line 77 in 52df65b
fe/crates/analyzer/src/traversal/expressions.rs
Line 89 in 52df65b
fe/crates/analyzer/src/traversal/expressions.rs
Line 108 in 52df65b
fe/crates/analyzer/src/traversal/functions.rs
Line 415 in 52df65b
fe/crates/analyzer/src/traversal/functions.rs
Line 426 in 52df65b
fe/crates/analyzer/src/traversal/functions.rs
Line 449 in 52df65b
assignable_expr
where we use values in both storage and memory.The text was updated successfully, but these errors were encountered: