Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better estimation of first-line column numbers #14

Open
hildjj opened this issue Feb 23, 2024 · 1 comment
Open

Better estimation of first-line column numbers #14

hildjj opened this issue Feb 23, 2024 · 1 comment

Comments

@hildjj
Copy link
Contributor

hildjj commented Feb 23, 2024

With the PR about to drop, line numbers will be correct from this code:

import peggy from "peggy-tag";

const parse123 = peggy`foo = $("f" "o"+)`;
console.log(parse123("foooo")); // "foooo"

but column numbers for errors thrown from the last line will be off by three. Find a way to determine where "foooo" actually starts.

@hildjj
Copy link
Contributor Author

hildjj commented Feb 23, 2024

From discord discussion, to reproduce:

Error.prepareStackTrace = (_, s) => s;

function createFunc() {
  return () => {
    const sites = new Error().stack;
    console.log(sites[1].getColumnNumber());
    console.log(sites[1].getFunctionName());
  };
}

const parse123 = createFunc();
parse123();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant