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

[Unity] Bug: Top level await: SyntaxError: Unexpected reserved word #1845

Open
3 tasks done
DoctorGester opened this issue Sep 22, 2024 · 1 comment
Open
3 tasks done
Assignees
Labels
bug Something isn't working Unity

Comments

@DoctorGester
Copy link

DoctorGester commented Sep 22, 2024

前置阅读 | Pre-reading

Puer的版本 | Puer Version

2.1.0

Unity的版本 | Unity Version

2023.1.13f1

发生在哪个平台 | Platform

Editor(mac)

错误信息 | Error Message

Exception: index:2: SyntaxError: Unexpected reserved word

SyntaxError: Unexpected reserved word
Puerts.GenericDelegate.Func[T1,TResult] (T1 p1) (at /Users/kirill.artemov/workspace/donkey/external/puerts/Runtime/Src/Default/JSType/GenericDelegate.cs:565)
Puerts.JsEnv.ExecuteModule (System.String specifier) (at /Users/kirill.artemov/workspace/donkey/external/puerts/Runtime/Src/Default/JsEnv.cs:324)
Log.TestPuerTs () (at Assets/Scripts/Log.cs:72)

问题重现 | Bug reproduce

    private class TestLoader : ILoader {
        private readonly ILoader fallback = new DefaultLoader();
        
        public bool FileExists(string filepath) {
            if (filepath.StartsWith("puerts")) {
                return fallback.FileExists(filepath);
            }
            
            return true;
        }

        public string ReadFile(string filepath, out string debugpath) {
            if (filepath.StartsWith("puerts")) {
                return fallback.ReadFile(filepath, out debugpath);
            }
            
            if (filepath == "index") {
                debugpath = "";
                return @"
                        await Promise.resolve(0);
                        export {};
                        ";
            }

            debugpath = null;
            return null;
        }
    }


    [RuntimeInitializeOnLoadMethod]
    private static void TestPuerTs() {
        var env = new JsEnv(new TestLoader());

        env.ExecuteModule("index");
    }

I saw that esm top-level await should have been supported here for V8 - c333e46

But it doesn't seem that it works. I'm using the manually downloaded V8 version from releases - https://github.com/Tencent/puerts/releases/download/Unity_v2.1.0/PuerTS_V8_2.1.0.tgz

I saw #1689 but it doesn't seem like there's been a clear resolution and that issue might have been outdated.

@DoctorGester DoctorGester added bug Something isn't working Unity labels Sep 22, 2024
@chexiongsheng
Copy link
Collaborator

Top level await disabled for some compatibility reason, may enable in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Unity
Projects
None yet
Development

No branches or pull requests

2 participants