curiosity-ai / h5

🚀 The next generation C# to JavaScript compiler
https://github.com/curiosity-ai/h5
Apache License 2.0
211 stars 30 forks source link

Incorrect async state-machine if any variable in the return block #23

Closed theolivenbaum closed 4 years ago

theolivenbaum commented 4 years ago

Originally reported here: Incorrect async state-machine behaviour causing both IF- and ELSE conditions to execute

Seems to be due this line: https://github.com/theolivenbaum/h5/blob/284112b3f50a9d75a9a359e6dfbeb0eda8d00954/H5/Compiler/Translator/Emitter/Blocks/AbstractEmitterBlock.Write.cs#L976

        public static bool IsReturnLast(string str)
        {
            str = str.TrimEnd();
            return str.EndsWith("return;") || Regex.IsMatch(str, "(?m:^)return(.*)?;$");
        }