Skip to content

Line after one-line if statement disappears #27

@Christilut

Description

@Christilut

This is my script:

console.log(1)

if (false) throw new Error('test')

console.log(2)

console.log(3)

I run it like this:

// this.jsContents is the the above script

const jsContentsExecutor: string = `async function _execute() {${this.jsContents}}; return _execute();`

const jsExecutor = sandbox.compileAsync(jsContentsExecutor)

  await jsExecutor({ 
//    _vars: pluginVars, // Normally some vars are added
//    _settings: pluginSettings
  }).run()

This is the output:

1
3

So it appears the 2 is disappearing.

If I change the line to have brackets, it does work:

if (false) { 
  throw new Error('test')
}

Results in:

1
2
3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions