From 7031e1dbd901d197f60348fda19d7164ea4fee7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Doeraene?= Date: Sun, 10 Mar 2024 13:34:12 +0100 Subject: [PATCH] Enable fatal warnings everywhere. --- build.sbt | 10 ++++++++++ wasm/src/main/scala/ir2wasm/WasmBuilder.scala | 8 ++++---- wasm/src/main/scala/wasm4s/Wasm.scala | 6 +++--- wasm/src/main/scala/wasm4s/WasmContext.scala | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 24843589..38ce8734 100644 --- a/build.sbt +++ b/build.sbt @@ -2,6 +2,16 @@ import org.scalajs.linker.interface.OutputPatterns val scalaV = "2.13.12" +inThisBuild(Def.settings( + scalacOptions ++= Seq( + "-encoding", + "utf-8", + "-feature", + "-deprecation", + "-Xfatal-warnings", + ) +)) + lazy val cli = project .in(file("cli")) .enablePlugins(ScalaJSPlugin) diff --git a/wasm/src/main/scala/ir2wasm/WasmBuilder.scala b/wasm/src/main/scala/ir2wasm/WasmBuilder.scala index ac4ec483..6c639ec4 100644 --- a/wasm/src/main/scala/ir2wasm/WasmBuilder.scala +++ b/wasm/src/main/scala/ir2wasm/WasmBuilder.scala @@ -32,9 +32,9 @@ class WasmBuilder { } } - def transformTopLevelExport(export: LinkedTopLevelExport)(implicit ctx: WasmContext): Unit = { + def transformTopLevelExport(topLevelExport: LinkedTopLevelExport)(implicit ctx: WasmContext): Unit = { implicit val fctx = WasmFunctionContext() - export.tree match { + topLevelExport.tree match { case d: IRTrees.TopLevelFieldExportDef => ??? case d: IRTrees.TopLevelJSClassExportDef => ??? case d: IRTrees.TopLevelMethodExportDef => transformToplevelMethodExportDef(d) @@ -370,11 +370,11 @@ class WasmBuilder { ) ctx.addFunction(func) - val export = new WasmExport.Function( + val exprt = new WasmExport.Function( methodName.value, func ) - ctx.addExport(export) + ctx.addExport(exprt) } private def genFunction( diff --git a/wasm/src/main/scala/wasm4s/Wasm.scala b/wasm/src/main/scala/wasm4s/Wasm.scala index 26c5af98..b61775f4 100644 --- a/wasm/src/main/scala/wasm4s/Wasm.scala +++ b/wasm/src/main/scala/wasm4s/Wasm.scala @@ -133,7 +133,7 @@ class WasmModule( def addFunctionType(typ: WasmFunctionType): Unit = _functionTypes.addOne(typ) def addRecGroupType(typ: WasmStructType): Unit = _recGroupTypes.addOne(typ) def addGlobal(typ: WasmGlobal): Unit = _globals.addOne(typ) - def addExport(export: WasmExport[_]) = _exports.addOne(export) + def addExport(exprt: WasmExport[_]) = _exports.addOne(exprt) def functionTypes = _functionTypes.toList def recGroupTypes = WasmModule.tsort(_recGroupTypes.toList) @@ -157,8 +157,8 @@ object WasmModule { } else { val found = noPreds.map { _._1 }.toSet val updated = hasPreds.map { - case (k, Some(v)) => // should be safe because hasPreds has no None - (k, if (found.contains(v)) None else Some(v)) + case (k, v) => + (k, v.filter(!found.contains(_))) } tsort(updated, done ++ found) } diff --git a/wasm/src/main/scala/wasm4s/WasmContext.scala b/wasm/src/main/scala/wasm4s/WasmContext.scala index 9f0d76d5..2cbf660b 100644 --- a/wasm/src/main/scala/wasm4s/WasmContext.scala +++ b/wasm/src/main/scala/wasm4s/WasmContext.scala @@ -96,7 +96,7 @@ trait FunctionTypeWriterWasmContext extends ReadOnlyWasmContext { this: WasmCont class WasmContext(val module: WasmModule) extends FunctionTypeWriterWasmContext { import WasmContext._ - def addExport(export: WasmExport[_]): Unit = module.addExport(export) + def addExport(exprt: WasmExport[_]): Unit = module.addExport(exprt) def addFunction(fun: WasmFunction): Unit = { module.addFunction(fun) functions.define(fun)