Skip to content

Julius arrow function with curly brace body is compiled to expression even if it's not an expression #270

@schoettl

Description

@schoettl

It looks like .julius is compiled to invalid JS in a certain situation:

When I use an arrow function which only contains one if statement, the compiler omits the curly braces of the function body. This roduces invalid JS: Uncaught SyntaxError: expected expression, got keyword 'if'

$(function() {
    $('.button').click(() => {
        if (!confirm('Really delete?'))
            return false
        //return // without this line .julius compiles this { ... } to just <expr> which doesn't compile
    })
})

compiled to:


$('.button').click(()=>if(!confirm('Wollen Sie die Reservierung wirklich stornieren?'))return false)

PS: Sorry, I never used Shakespeare alone, so I don't know how to provide a minimal example.

I can't work on this issue right now, only wanted to have it documented somewhere.

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