You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a data constructor has the same name as an imported module, in the generated javascript they also have the same name resulting in an error when run
Here is a minimal example
Bar.purs
moduleBarwhereimportPrelude-- This function does not do anything it only needs to be significantly complicated-- so that it won't be inlined and instead the module it is in importedplaceHolder::Int->String
placeHolder i |mod2 i ==0="2"
placeHolder i |mod3 i ==0="2"
placeHolder i |mod5 i ==0="2"
placeHolder i |mod7 i ==0="2"
placeHolder _ ="yipee"
Main.purs
moduleMainwhereimportPreludeimportBar (placeHolder)
importEffect (Effect)
importEffect.Console (log)
dataFooBar=Foo | Barmain::EffectUnit
main =do-- use placeholder to ensure it is actually in the generated javascriptlog$ placeHolder 3
Here Bar is the name of a data constructor for the `FooBar' type and the name of a module
The generated javascript using purescript-backend-optimizer is:
✘ [ERROR] The symbol "Bar" has already been declared
output-es/Main/index.js:5:6:
5 │ const Bar = /* #__PURE__ */ $FooBar("Bar");
╵ ~~~
The symbol "Bar" was originally declared here:
output-es/Main/index.js:1:12:
1 │ import * as Bar from "../Bar/index.js";
╵ ~~~
The default purescript backend renames the imported module to "Bar_1" when generating the javascript removing the name clash and this seems like the easiest way to fix this issue.
Javascript generated by default backend
When a data constructor has the same name as an imported module, in the generated javascript they also have the same name resulting in an error when run
Here is a minimal example
Bar.purs
Main.purs
Here Bar is the name of a data constructor for the `FooBar' type and the name of a module
The generated javascript using purescript-backend-optimizer is:
Running this gives an error
The default purescript backend renames the imported module to "Bar_1" when generating the javascript removing the name clash and this seems like the easiest way to fix this issue.
Javascript generated by default backend
purs-backend-es v1.4.2 used
The text was updated successfully, but these errors were encountered: