Skip to content

Commit e76f4d3

Browse files
committed
Fix bug that drops srcloc on withUnit calls
1 parent 6d1de41 commit e76f4d3

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/arr/trove/error.arr

+2-4
Original file line numberDiff line numberDiff line change
@@ -2459,12 +2459,10 @@ data RuntimeError:
24592459
self.render-reason()
24602460
end
24612461
end,
2462-
method render-reason(self):
2462+
method render-reason(self) block:
24632463
base-err = [ED.para:
24642464
ed-simple-intro("unit annotation", self.loc),
2465-
ED.text("The annotation at "),
2466-
ED.loc(self.loc),
2467-
ED.text(" is annotated with the unit "),
2465+
ED.text("The annotation is annotated with the unit "),
24682466
ED.code(ED.text(self.unit-str)),
24692467
ED.text(" but does not support unit annotations.")]
24702468
if self.loc.is-builtin():

src/js/base/runtime.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2935,15 +2935,15 @@ function (Namespace, jsnums, codePoint, util, exnStackParser, loader, seedrandom
29352935
}
29362936
function makeUnitAnn(ann, u, srcloc) {
29372937
if (ann.withUnit === undefined) {
2938-
thisRuntime.ffi.throwUnitsOnUnsupportedAnn(jsnums.unitToString(u), makeSrcloc(srcloc));
2938+
thisRuntime.ffi.throwUnitsOnUnsupportedAnn(jsnums.unitToString(u), srcloc);
29392939
}
2940-
return ann.withUnit(u);
2940+
return ann.withUnit(u, srcloc);
29412941
}
29422942
PUnitAnn.prototype.withUnit = function(unit, srcloc) {
29432943
if (this.implicit || jsnums.checkUnit(this.u, unit)) {
29442944
return new PUnitAnn(this.ann, unit, false);
29452945
} else {
2946-
thisRuntime.ffi.throwUnitsOnUnsupportedAnn(jsnums.unitToString(unit), makeSrcloc(srcloc));
2946+
thisRuntime.ffi.throwUnitsOnUnsupportedAnn(jsnums.unitToString(unit), srcloc);
29472947
}
29482948
}
29492949
PUnitAnn.prototype.check = function(compilerLoc, val) {

src/js/trove/ffi.js

+1
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@
500500
raise(makeModuleLoadFailureL(names));
501501
}
502502
function throwUnitsOnUnsupportedAnn(unitStr, loc) {
503+
loc = runtime.makeSrcloc(loc);
503504
runtime.checkString(unitStr);
504505
raise(err("units-on-unsupported-ann")(loc, unitStr));
505506
}

0 commit comments

Comments
 (0)