[valueblocks] split working test and aliasing bug case

This commit is contained in:
Joe Savona
2023-01-31 13:39:34 -08:00
parent 096482e5cb
commit aca0e27012
5 changed files with 85 additions and 29 deletions
@@ -0,0 +1,57 @@
## Input
```javascript
function component(props) {
// The mutable range for a extens the entire body.
// commenting out the last line of InferMutableRanges fixes it.
// my guess of what's going on is that a is aliased into the return value object literal,
// and that alias makes it look like the range of a needs to be extended to that point.
// but what's weird is that the end of a's range doesn't quite extend to the object.
let a = props.a || (props.b && props.c && props.d);
let b = (props.a && props.b && props.c) || props.d;
return { a, b };
}
```
## Code
```javascript
function component(props) {
const $ = React.useMemoCache();
const c_0 = $[0] !== props;
let a;
if (c_0) {
a = props.a || (props.b && props.c && props.d);
const c_2 = $[2] !== props;
let t3;
if (c_2) {
t3 = (props.a && props.b && props.c) || props.d;
$[2] = props;
$[3] = t3;
} else {
t3 = $[3];
}
$[0] = props;
$[1] = a;
} else {
a = $[1];
}
const b = t3;
const c_4 = $[4] !== a;
const c_5 = $[5] !== b;
let t6;
if (c_4 || c_5) {
t6 = { a: a, b: b };
$[4] = a;
$[5] = b;
$[6] = t6;
} else {
t6 = $[6];
}
return t6;
}
```
@@ -0,0 +1,10 @@
function component(props) {
// The mutable range for a extens the entire body.
// commenting out the last line of InferMutableRanges fixes it.
// my guess of what's going on is that a is aliased into the return value object literal,
// and that alias makes it look like the range of a needs to be extended to that point.
// but what's weird is that the end of a's range doesn't quite extend to the object.
let a = props.a || (props.b && props.c && props.d);
let b = (props.a && props.b && props.c) || props.d;
return { a, b };
}
@@ -55,10 +55,7 @@ function Component(props) {
}
for (let i = 0; i < items.length; i = i + 1, i) {
const item = items.at(i);
if (item == null) {
} else {
}
if (seen.has(item)) {
if (item == null || seen.has(item)) {
continue;
}
@@ -2,14 +2,10 @@
## Input
```javascript
// @only
function component(props) {
let a = props.a || (props.b && props.c && props.d);
let b = (props.a && props.b && props.c) || props.d;
return { a, b };
// let b = props.c || props.d;
// let c = props.e ?? props.f;
// return ((a && b) || c) ?? null;
return a ?? b;
}
```
@@ -17,33 +13,33 @@ function component(props) {
## Code
```javascript
// @only
function component(props) {
const $ = React.useMemoCache();
const c_0 = $[0] !== props;
let a;
let t1;
if (c_0) {
a = props.a || (props.b && props.c && props.d);
const c_2 = $[2] !== props;
let t3;
if (c_2) {
t3 = (props.a && props.b && props.c) || props.d;
$[2] = props;
$[3] = t3;
} else {
t3 = $[3];
}
t1 = props.a || (props.b && props.c && props.d);
$[0] = props;
$[1] = a;
$[1] = t1;
} else {
a = $[1];
t1 = $[1];
}
const a = t1;
const c_2 = $[2] !== props;
let t3;
if (c_2) {
t3 = (props.a && props.b && props.c) || props.d;
$[2] = props;
$[3] = t3;
} else {
t3 = $[3];
}
const b = t3;
const c_4 = $[4] !== a;
const c_5 = $[5] !== b;
let t6;
if (c_4 || c_5) {
t6 = { a: a, b: b };
t6 = a ?? b;
$[4] = a;
$[5] = b;
$[6] = t6;
@@ -1,9 +1,5 @@
// @only
function component(props) {
let a = props.a || (props.b && props.c && props.d);
let b = (props.a && props.b && props.c) || props.d;
return { a, b };
// let b = props.c || props.d;
// let c = props.e ?? props.f;
// return ((a && b) || c) ?? null;
return a ?? b;
}