compiler icon indicating copy to clipboard operation
compiler copied to clipboard

🐛 Blocks don't emit correct code when they are the body of a `where` case.

Open hayleigh-dot-dev opened this issue 3 years ago • 0 comments

Something like:

pub let main = _ =>
    where Process.argv 
        is [ _, _, "make", dir ] => {
            ret 0
        } 

emits:

export function main (_) {
    return (($match) => {
        if ($match.length >= 4 && true && true && $match[2] === "make") {
            const dir = $match[3]

            return {
                const _ = Console.log (dir)

                return 0
            }
        }
    
        ...

I think we have a mechanism at the moment to determine whether something should be wrapped in an IIFE or not - we're probably just ignoring that by accident.

In the future we should bring back @Alpvax's work from the previous version where IIFEs weren't emitted in certain cases where a normal JavaScript block would suffice.

hayleigh-dot-dev avatar Feb 21 '22 00:02 hayleigh-dot-dev