From 6da87e3478b705f2b95dce715534979739f27412 Mon Sep 17 00:00:00 2001 From: DieMyst Date: Mon, 30 Oct 2023 17:50:57 +0700 Subject: [PATCH] add scalafmt, use only one nil --- .scalafmt.conf | 10 +++++----- model/raw/src/main/scala/aqua/raw/value/ValueRaw.scala | 1 - .../scala/aqua/semantics/rules/ValuesAlgebra.scala | 3 +++ .../aqua/semantics/rules/names/NamesInterpreter.scala | 2 +- .../test/scala/aqua/semantics/AssignmentSemSpec.scala | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 16e4dbac..a89b2727 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -62,9 +62,9 @@ runner { } } -rewrite { - rules = [ - SortImports - ] -} +rewrite.rules = [Imports] +rewrite.imports.sort = ascii +rewrite.imports.groups = [ + ["aqua\\..*"] +] #runner.dialect = scala3 diff --git a/model/raw/src/main/scala/aqua/raw/value/ValueRaw.scala b/model/raw/src/main/scala/aqua/raw/value/ValueRaw.scala index 6ac5ea23..19abc606 100644 --- a/model/raw/src/main/scala/aqua/raw/value/ValueRaw.scala +++ b/model/raw/src/main/scala/aqua/raw/value/ValueRaw.scala @@ -34,7 +34,6 @@ object ValueRaw { val ParticleTimestamp: LiteralRaw = LiteralRaw("%timestamp%", ScalarType.u64) val Nil: LiteralRaw = LiteralRaw("[]", StreamType(BottomType)) - val VarNil: VarRaw = VarRaw("nil", StreamType(BottomType)) /** * Type of error value diff --git a/semantics/src/main/scala/aqua/semantics/rules/ValuesAlgebra.scala b/semantics/src/main/scala/aqua/semantics/rules/ValuesAlgebra.scala index f5b2d7b7..67d06de2 100644 --- a/semantics/src/main/scala/aqua/semantics/rules/ValuesAlgebra.scala +++ b/semantics/src/main/scala/aqua/semantics/rules/ValuesAlgebra.scala @@ -78,6 +78,9 @@ class ValuesAlgebra[S[_], Alg[_]: Monad](using case l @ LiteralToken(_, t) => LiteralRaw(l.value, t).some.pure[Alg] + case VarToken(name) if name.value == ValueRaw.Nil.value => + ValueRaw.Nil.some.pure[Alg] + case VarToken(name) => N.read(name, mustBeDefined = false).flatMap { case Some(t) => diff --git a/semantics/src/main/scala/aqua/semantics/rules/names/NamesInterpreter.scala b/semantics/src/main/scala/aqua/semantics/rules/names/NamesInterpreter.scala index 7ed42320..9944f701 100644 --- a/semantics/src/main/scala/aqua/semantics/rules/names/NamesInterpreter.scala +++ b/semantics/src/main/scala/aqua/semantics/rules/names/NamesInterpreter.scala @@ -134,7 +134,7 @@ class NamesInterpreter[S[_], X](using override def assign(name: Name[S], value: ValueRaw): SX[Boolean] = value match { - case ValueRaw.Nil | ValueRaw.VarNil => + case ValueRaw.Nil => report .error( name, diff --git a/semantics/src/test/scala/aqua/semantics/AssignmentSemSpec.scala b/semantics/src/test/scala/aqua/semantics/AssignmentSemSpec.scala index 8caafd9a..5715a3b0 100644 --- a/semantics/src/test/scala/aqua/semantics/AssignmentSemSpec.scala +++ b/semantics/src/test/scala/aqua/semantics/AssignmentSemSpec.scala @@ -15,7 +15,7 @@ import org.scalatest.matchers.should.Matchers class AssignmentSemSpec extends AnyFlatSpec with Matchers with Inside { - import Utils.{*, given} + import Utils.{given, *} val program: Prog[State[CompilerState[cats.Id], *], Raw] = { val expr = ClosureExpr(Name[Id]("closure"), None)