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.)
23 lines
531 B
Text
23 lines
531 B
Text
(int, int, int, int) compute_data_size?(cell c, int max_cells) pure asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT";
|
|
builder begin_cell() pure asm "NEWC";
|
|
cell end_cell(builder b) pure asm "ENDC";
|
|
|
|
(int, int) validate_input(cell input) pure {
|
|
var (x, y, z, correct) = compute_data_size?(input, 10);
|
|
throw_unless(102, correct);
|
|
}
|
|
|
|
int main() pure {
|
|
cell c = begin_cell().end_cell();
|
|
validate_input(c);
|
|
return 0;
|
|
}
|
|
|
|
{-
|
|
@compilation_should_fail
|
|
@stderr
|
|
"""
|
|
An impure operation in a pure function
|
|
throw_unless
|
|
"""
|
|
-}
|