Skip to content

Commit

Permalink
fixup! fixup! Functions with locals of structs with lifecycle hooks a…
Browse files Browse the repository at this point in the history
…re not pure.
  • Loading branch information
bbannier committed May 16, 2023
1 parent 38cb476 commit f5995bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/Baseline/hilti.optimization.dead_code/opt.hlt
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
module foo {

type X = struct {
type Y = struct {
hook void ~finally() {}
};

global uint<64> num_calls = 0;

function X fn_pure3() &pure {
local X x;
return x;
function Y fn_pure4() {
local Y y;
return y;
}

function uint<64> fn_not_pure() {
num_calls += 1;
return 0;
}

fn_pure3();
fn_pure4();
fn_not_pure();

}
9 changes: 9 additions & 0 deletions tests/hilti/optimization/dead_code.hlt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ function X fn_pure3() {
return x;
}

type Y = struct {
hook void ~finally() {}
};
function Y fn_pure4() {
local Y y;
return y;
}

global uint<64> num_calls = 0;
function uint<64> fn_not_pure() {
num_calls += 1;
Expand All @@ -27,6 +35,7 @@ default<void>();
fn_pure1();
fn_pure2();
fn_pure3();
fn_pure4();
fn_not_pure();

}

0 comments on commit f5995bf

Please sign in to comment.