Skip to content

Commit f8ce3f3

Browse files
patricklxNullVoxPopuli
authored andcommitted
add debug alias for let
1 parent 34888e9 commit f8ce3f3

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

bin/run-tests.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
21
// @ts-check
32

43
import child from 'child_process';
54
import { resolve } from 'path';
65
import PCR from 'puppeteer-chromium-resolver';
76
import { fileURLToPath } from 'url';
87

9-
108
const { puppeteer, executablePath } = await PCR({});
119

1210
const __root = fileURLToPath(new URL('..', import.meta.url));

packages/@glimmer-workspace/integration-tests/test/strict-mode-test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,20 @@ class DynamicStrictModeTest extends RenderTest {
12191219
}, /Expected a dynamic component definition, but received an object or function that did not have a component manager associated with it. The dynamic invocation was `<this.Foo>` or `\{\{this.Foo\}\}`, and the incorrect definition is the value at the path `this.Foo`, which was:/u);
12201220
}
12211221

1222+
@test
1223+
'Throws an error with correct debug label if a non-component is used as a component'() {
1224+
const Foo = defineSimpleHelper(() => 'Hello, world!');
1225+
const Bar = defineComponent({}, '{{#let this.Foo as |foo|}}<foo/>{{/let}}', {
1226+
definition: class extends GlimmerishComponent {
1227+
Foo = Foo;
1228+
},
1229+
});
1230+
1231+
this.assert.throws(() => {
1232+
this.renderComponent(Bar);
1233+
}, /Expected a dynamic component definition, but received an object or function that did not have a component manager associated with it. The dynamic invocation was `<foo>` or `\{\{foo\}\}`, and the incorrect definition is the value at the path `foo`, which was:/u);
1234+
}
1235+
12221236
@test
12231237
'Can pass helper as argument and invoke dynamically'() {
12241238
const plusOne = defineSimpleHelper(() => 'Hello, world!');

packages/@glimmer/reference/lib/reference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function createConstRef<T>(value: T, debugLabel: false | string): Referen
8282
ref.tag = CONSTANT_TAG;
8383

8484
if (import.meta.env.DEV) {
85-
ref.debugLabel = debugLabel as string;
85+
ref.debugLabel = (debugLabel as string) || String(value);
8686
}
8787

8888
return ref;

packages/@glimmer/runtime/lib/compiled/opcodes/expressions.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ import { getInternalHelperManager } from '@glimmer/manager';
2222
import {
2323
childRefFor,
2424
createComputeRef,
25+
createDebugAliasRef,
2526
FALSE_REFERENCE,
2627
TRUE_REFERENCE,
2728
UNDEFINED_REFERENCE,
2829
valueForRef,
2930
} from '@glimmer/reference';
3031
import { assert, assign, debugToString, decodeHandle, isObject } from '@glimmer/util';
31-
import { $v0, CurriedTypes, Op } from '@glimmer/vm';
32+
import { $s0, $v0, CurriedTypes, Op } from '@glimmer/vm';
3233

3334
import { isCurriedType, resolveCurriedValue } from '../../curried-value';
3435
import { APPEND_OPCODES } from '../../opcodes';
@@ -170,6 +171,12 @@ APPEND_OPCODES.add(Op.GetVariable, (vm, { op1: symbol }) => {
170171

171172
APPEND_OPCODES.add(Op.SetVariable, (vm, { op1: symbol }) => {
172173
let expr = check(vm.stack.pop(), CheckReference);
174+
if (import.meta.env.DEV) {
175+
let state = vm.fetchValue($s0);
176+
let symbols = (state as any)?.table?.symbols;
177+
let sym = symbol === 0 ? 'this' : symbols?.[symbol - 1];
178+
expr = createDebugAliasRef!(sym, expr);
179+
}
173180
vm.scope().bindSymbol(symbol, expr);
174181
});
175182

packages/@glimmer/syntax/test/plugin-node-test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,17 @@ test('deprecated program visitor', (assert) => {
4848
return {
4949
name: 'plugin',
5050
visitor: {
51-
Program(node: AST.Program) {
51+
Template(node: AST.Template) {
5252
assert.step(node.type);
5353
},
5454

5555
BlockStatement(node: AST.BlockStatement) {
5656
assert.step(node.type);
5757
},
58+
59+
Block(node: AST.Block) {
60+
assert.step(node.type);
61+
},
5862
},
5963
};
6064
};

0 commit comments

Comments
 (0)