Skip to content

[Question] Incorrect line when throwing string #799

Closed
@ABBAPOH

Description

@ABBAPOH

Let's say I have a file test.js

function foo() {
    var path = "foo";
    if (true)
        throw "fail1";
    return path;
}
foo();

Now I call JS_EvalThis on this piece of code and get a backtrace

    at /Users/abbapoh/Developer/qbs/qbs/tests/auto/language/testdata/test.js:1:1
    at <eval> (/Users/abbapoh/Developer/qbs/qbs/tests/auto/language/testdata/test.js:7:1

When changing the line to new throw Error("fail1");, I get test.js:4:19, as expected.
In order to catch strings as errors, we added a wrapper to turn them into Errors like this https://github.com/qbs/quickjs-ng/blob/qbs/quickjs.c#L17483-L17489
This used to be working with the old engine. From what I debugged, find_line_num can't guess the line anymore.
Am I doing this wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions