lezer-parser/php

Illegal redeclared variable: global

Closed this issue · 9 comments

I'm getting an error when trying to compile this in a ClojureScript project that looks like this:

Closure compilation failed with 1 errors
--- node_modules/@lezer/php/dist/index.cjs:50
Illegal redeclared variable: global

Here's a branch of a repo that replicates the error. I don't have time to check if this happens in a JS project too.

There's no restriction in JavaScript against declaring a variable named global, so I'd say this is a problem with ClojureScript.

Yes, we renamed the variable to _global manually and it started working. :P

This is a problem with google/closure-compiler (discovered via google/closure-compiler#2471).

Right. Closing this, since I don't plan to accommodate it on this side.

@marijnh so.. this gives an error and make the package unusable, what can we do?

PS: im not using clojure, just js + vite

what can we do?

Figure out what's going wrong, possibly open a new bug if you think this package is to blame. Declaring a variable named global locally is valid JavaScript, so I suspect you're using some build/runtime tool that is broken.

what can we do?

Figure out what's going wrong, possibly open a new bug if you think this package is to blame. Declaring a variable named global locally is valid JavaScript, so I suspect you're using some build/runtime tool that is broken.

i changed globalfor _global and it works. can I submit a PR? I'm using typescript, node and vite, nothing special

I really don't want to adjust code to work around bugs, especially untriaged bugs, in other software.

I really don't want to adjust code to work around bugs, especially untriaged bugs, in other software.

what other software? typescript/vite you mean? there is already a lot of variables that start with _, like _interface, so why not just have another? why you want this grammar to break when no other does? It's just changing a variable name that doesn't affect anything.

I can help you debug the issue if you guide me or tell me what you need, but I'm using node, not a weird broken runtime. I don't understand why you don't want to fix this. It's easy and doesn't cause any trouble.

10:20:34 AM [vite] Internal server error: Identifier 'global' has already been declared

I don't know where the problem really is, but all the things I'm using are so popular, so i'm not the last one encountering this issue.

If you don't want to fix the grammar, it's ok.