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

Loose parser incorrect parsing with incoherent indentation #683

Closed
pantoninho opened this issue Mar 12, 2018 · 1 comment
Closed

Loose parser incorrect parsing with incoherent indentation #683

pantoninho opened this issue Mar 12, 2018 · 1 comment

Comments

@pantoninho
Copy link

pantoninho commented Mar 12, 2018

Acorn's loose parser incorrectly parses code if the indentation is not coherent.
This problem does not occur with the main parser.

Sorry for the brief report, will update with more details soon (if needed).

sample test:

const acorn = require('acorn');
const { parse_dammit } = require('acorn/dist/acorn_loose');
const escodegen = require('escodegen');

const code = `
{
        console.log('should be inside block');
    console.log('should be inside block');
}
console.log('should be outside block');
`;

console.log('\n----------- ACORN PARSER -----------');
console.log(escodegen.generate(acorn.parse(code)));
console.log('\n-------- ACORN LOOSE PARSER --------');
console.log(escodegen.generate(parse_dammit(code)));

loose parser output:

{
    console.log('should be inside block');
}
console.log('should be inside block');
console.log('should be outside block');
@marijnh
Copy link
Member

marijnh commented Mar 13, 2018

That is by design. See #199 for more discussion.

@marijnh marijnh closed this as completed Mar 13, 2018
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

2 participants