mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-15 04:32:21 +00:00
In stdlib, all existing pure functions are asm-implemented. But since we introduced a `pure` keyword applicable to user-defined functions, we need to check that they won't have any side effects (exceptions, globals modification, etc.)
25 lines
390 B
Text
25 lines
390 B
Text
builder begin_cell() pure asm "NEWC";
|
|
|
|
global int g;
|
|
|
|
(builder) f_pure() pure {
|
|
var g; // strange, but this doesn't make a variable local, it still refers to a global one
|
|
builder b = begin_cell();
|
|
g = g + 1;
|
|
return b;
|
|
}
|
|
|
|
int main() {
|
|
g = 0;
|
|
f_pure();
|
|
return g;
|
|
}
|
|
|
|
{-
|
|
@compilation_should_fail
|
|
@stderr
|
|
"""
|
|
An impure operation in a pure function
|
|
g = g + 1;
|
|
"""
|
|
-}
|