-
Notifications
You must be signed in to change notification settings - Fork 135
Open
Labels
bugSomething isn't workingSomething isn't working
Description
error
function heavily relies on source_idx
, which results in the function itself not being able to be used after parsing phase completed, as first saw in #220.
Lines 1123 to 1144 in 11785eb
/* Construct error source diagnostics, enabling precise identification of | |
* syntax and logic issues within the code. | |
*/ | |
int offset, start_idx, i = 0; | |
char diagnostic[512 /* MAX_LINE_LEN * 2 */]; | |
for (offset = SOURCE->size; offset >= 0 && SOURCE->elements[offset] != '\n'; | |
offset--) | |
; | |
start_idx = offset + 1; | |
for (offset = 0; | |
offset < MAX_SOURCE && SOURCE->elements[start_idx + offset] != '\n'; | |
offset++) { | |
diagnostic[i++] = SOURCE->elements[start_idx + offset]; | |
} | |
diagnostic[i++] = '\n'; | |
for (offset = start_idx; offset < SOURCE->size; offset++) { | |
diagnostic[i++] = ' '; | |
} |
Possible fixes
One possible fix to address this issue is to instead of relying on global counter (source_idx
), we stores lexical position within an AST's node, and by passing an node instance to properly report an error at correct lexical position.
Workarounds
It's advised to use fatal
function after parsing phase is completed before behavior of error
function is fixed.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working