Thanks for the feedback. I have just released version 3.13.1 with an additional major change: a rewriting of the error reporting system, with an implementation of PEP 657, the one that explains how to generate reports like
>>> (1 /
... ( 2 -
... 2))
Traceback (most recent call last):
File "<python-input-18>", line 1, in <module>
(1 /
~~^
( 2 -
~~~~~
2))
~~
ZeroDivisionError: division by zero
>>>
with these funny ~ and ^.
CPython uses the instruction number in the generated bytecode; these is no such thing in Javascript so I had to implement something to simulate it.
For code like
x / 2
the generated Javascript now includes these lines
frame.positions = [[2,2,0,5]] # (1)
$B.rich_op('__truediv__', locals.x, 2, 1) # (2)
In (1) an array frame.positions is created, indicating the location of an instruction by a 4-element list [lineno, end_lineno, col_offset, end_col_offset].
In (2), an "instruction number" is passed as the last argument of the internal function rich_op. If this function raises an exception, the instruction number is used in association with frame.positions to determine the location of the problematic instruction in the source code and generate the error trace.
It was fun to develop it, but tricky so there might be remaining bugs here and there.