Skip to content

Commit feffddb

Browse files
cknittclaude
andcommitted
Print the this binding of a method without a space before the semicolon
The space was left over from when the printer spelled out `let self =` by hand; no other statement puts a space before its semicolon. JS modified (@this function): Example: let even = @this (o, x) => x + o Before (js): let o = this ; After (js): let o = this; Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kbf3gJuq6rWZULJVY3ATmY Signed-off-by: Christoph Knittel <ck@cca.io>
1 parent 804df1b commit feffddb

5 files changed

Lines changed: 14 additions & 15 deletions

File tree

‎compiler/core/js_dump.ml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ let pp_var_assign cxt f id =
253253
let pp_var_assign_this cxt f id =
254254
let cxt = pp_var_assign cxt f id in
255255
P.string f L.this;
256-
P.space f;
257256
semi f;
258257
P.newline f;
259258
cxt

‎tests/tests/src/ThisPpxBridge.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33

44
function methodThroughPpxBridge() {
5-
let $$this = this ;
5+
let $$this = this;
66
return 1 + $$this | 0;
77
}
88

99
function bracedMethodThroughPpxBridge() {
10-
let $$this = this ;
10+
let $$this = this;
1111
return 1 + $$this | 0;
1212
}
1313

‎tests/tests/src/UncurriedExternals.mjs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ let tcr = {};
3131

3232
function tsiC(c) {
3333
c.increment = function (amount) {
34-
let me = this ;
34+
let me = this;
3535
console.log(me);
3636
};
3737
}
3838

3939
function tsiU(c) {
4040
c.increment = function (amount) {
41-
let me = this ;
41+
let me = this;
4242
console.log(me);
4343
};
4444
}
@@ -65,13 +65,13 @@ let StandardNotation = {
6565
};
6666

6767
function methodWithAsync() {
68-
let $$this = this ;
68+
let $$this = this;
6969
return async arg => $$this + arg | 0;
7070
}
7171

7272
let p1 = {
7373
watch: async function (name, ev) {
74-
let pc = this ;
74+
let pc = this;
7575
console.log(pc);
7676
}
7777
};

‎tests/tests/src/test_bs_this.mjs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33

44
function uux_this(x, y) {
5-
let o = this ;
5+
let o = this;
66
return (o.length + x | 0) + y | 0;
77
}
88

99
function even(x) {
10-
let o = this ;
10+
let o = this;
1111
return x + o | 0;
1212
}
1313

1414
function bark() {
1515
return function (x, y) {
16-
let o = this ;
16+
let o = this;
1717
console.log([
1818
o.length,
1919
o.x,
@@ -27,19 +27,19 @@ function bark() {
2727

2828
let js_obj = {
2929
bark: function (x, y) {
30-
let o = this ;
30+
let o = this;
3131
console.log(o);
3232
return x + y | 0;
3333
}
3434
};
3535

3636
function f(x) {
3737
x.onload = function () {
38-
let o = this ;
38+
let o = this;
3939
console.log(o);
4040
};
4141
return x.addEventListener("onload", function () {
42-
let o = this ;
42+
let o = this;
4343
console.log(o.response);
4444
});
4545
}

‎tests/tests/src/this_directive.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
function plain(x) {
55
'use cache';
6-
let self = this ;
6+
let self = this;
77
return self + x | 0;
88
}
99

1010
async function action(x) {
1111
'use server';
12-
let self = this ;
12+
let self = this;
1313
return self + x | 0;
1414
}
1515

0 commit comments

Comments
 (0)