Commit 55d44fd
Route Lambda.apply's eta reduction through the folding constructors
lambda.mli says a term is built through the constructors, seven of which
normalize as they build. apply did not: its eta reduction substituted the
call's arguments into the inner primitive and then rebuilt the result with a
raw Lprim, so a primitive applied to constants was left unfolded.
((a, b) => a + b)(1, 2)
left translation as (+ 1 2) rather than 3. It could only do this by owning
the type; the reason it did was position, which the preceding commit fixed.
Generated JavaScript is unchanged: the optimizer passes were folding this on
their way past, so the same code comes out. It now happens once, at
construction, instead of being rediscovered on every full-tree rebuild.
Two of the three raw constructions in lambda.ml remain - offset_ref and
mk_builtin. Neither is a tidy-up: mk_builtin makes constant guards fold at
production, which is only safe since guards became data, and offset_ref is
untested.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W8g8qwBARAcvW9MyuKQq8H1 parent 247619d commit 55d44fd
1 file changed
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1043 | 1043 | | |
1044 | 1044 | | |
1045 | 1045 | | |
1046 | | - | |
1047 | | - | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
1048 | 1049 | | |
1049 | 1050 | | |
1050 | 1051 | | |
| |||
1053 | 1054 | | |
1054 | 1055 | | |
1055 | 1056 | | |
1056 | | - | |
| 1057 | + | |
1057 | 1058 | | |
1058 | 1059 | | |
1059 | 1060 | | |
| |||
1066 | 1067 | | |
1067 | 1068 | | |
1068 | 1069 | | |
1069 | | - | |
| 1070 | + | |
1070 | 1071 | | |
1071 | 1072 | | |
1072 | 1073 | | |
| |||
1075 | 1076 | | |
1076 | 1077 | | |
1077 | 1078 | | |
1078 | | - | |
| 1079 | + | |
1079 | 1080 | | |
1080 | 1081 | | |
1081 | 1082 | | |
| |||
0 commit comments