temperlang / temper

3 stars 0 forks source link

Keyword `default` not detected in JS. #119

Open ShawSumma opened 7 months ago

ShawSumma commented 7 months ago

The keyword default is not detected in some JS contexts... a way to have an alt would be nice.

export class Fallback {
  public list: List<Int>;
  public default: Int;
}

@ben-509 might be working on similar stuff, so i'll assign him.


java.lang.IllegalArgumentException: -work//tree.temper+1007: `default` is a JS reserved word
        at lang.temper.be.js.Js$Identifier.<init>(Js.kt:778)
        at lang.temper.be.js.JsTranslator.decomposeMemberKey(JsTranslator.kt:1524)
        at lang.temper.be.js.JsTranslator.translateClassType(JsTranslator.kt:1009)
        at lang.temper.be.js.JsTranslator.translateTypeDeclaration(JsTranslator.kt:846)
        at lang.temper.be.js.JsTranslator.translateTopLevel(JsTranslator.kt:1165)
        at lang.temper.be.js.JsTranslator.access$translateTopLevel(JsTranslator.kt:79)
        at lang.temper.be.js.JsTranslator$translate$1$2$1.invoke(JsTranslator.kt:139)
        at lang.temper.be.js.JsTranslator$translate$1$2$1.invoke(JsTranslator.kt:138)
        at lang.temper.be.js.JsTranslator.withDependencyMode(JsTranslator.kt:110)
        at lang.temper.be.js.JsTranslator.access$withDependencyMode(JsTranslator.kt:79)
        at lang.temper.be.js.JsTranslator$translate$1.invoke(JsTranslator.kt:138)
        at lang.temper.be.js.JsTranslator$translate$1.invoke(JsTranslator.kt:124)
        at lang.temper.be.js.JsNames.forOrigin(JsNames.kt:31)
        at lang.temper.be.js.JsTranslator.translate(JsTranslator.kt:124)
        at lang.temper.be.js.JsBackend.translate(JsBackend.kt:228)
        at lang.temper.compile.handlers.TranslationManager.doTranslate(TranslationManager.kt:523)
        at lang.temper.compile.handlers.TranslationManager.access$doTranslate(TranslationManager.kt:42)
        at lang.temper.compile.handlers.TranslationManager$doFinishTmpL$1$1.invoke(TranslationManager.kt:515)
        at lang.temper.compile.handlers.TranslationManager$doFinishTmpL$1$1.invoke(TranslationManager.kt:514)
        at lang.temper.common.currents.Currents$newComputedFuture$1.invoke(Currents.kt:102)
        at lang.temper.common.currents.Currents$newComputedFuture$1.invoke(Currents.kt:101)
        at lang.temper.common.currents.Currents$newComputedResultFuture$1$1.invoke(Currents.kt:116)
        at lang.temper.common.currents.Currents$newComputedResultFuture$1$1.invoke(Currents.kt:113)
        at lang.temper.common.currents.Currents$TaskImpl.run(Currents.kt:261)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)```
tjpalmer commented 7 months ago

I mostly fixed this in a PR merged earlier today. It would replace default with default_ in the js backend. Not ideal for every case, but once we get more name override control, it should be possible to make custom alternatives.

tjpalmer commented 7 months ago

See also #114 that I closed with said PR.