diff --git a/interpreter/shared/src/main/scala/sigmastate/Values.scala b/interpreter/shared/src/main/scala/sigmastate/Values.scala index 016177f760..d5326db2b1 100644 --- a/interpreter/shared/src/main/scala/sigmastate/Values.scala +++ b/interpreter/shared/src/main/scala/sigmastate/Values.scala @@ -878,31 +878,6 @@ object Values { def apply(items: Value[SType]*): Tuple = Tuple(items.toIndexedSeq) } - trait OptionValue[T <: SType] extends Value[SOption[T]] { - } - - // TODO v5.x (4h): SomeValue and NoneValue are not used in ErgoTree and can be - // either removed or implemented in v6.0 - case class SomeValue[T <: SType](x: Value[T]) extends OptionValue[T] { - override def companion = SomeValue - val tpe = SOption(x.tpe) - def opType = SFunc(x.tpe, tpe) - } - object SomeValue extends ValueCompanion { - override val opCode = SomeValueCode - override def costKind: CostKind = Constant.costKind - } - - case class NoneValue[T <: SType](elemType: T) extends OptionValue[T] { - override def companion = NoneValue - val tpe = SOption(elemType) - def opType = SFunc(elemType, tpe) - } - object NoneValue extends ValueCompanion { - override val opCode = NoneValueCode - override def costKind: CostKind = Constant.costKind - } - /** ErgoTree node which converts a collection of expressions into a collection of data * values. Each data value of the resulting collection is obtained by evaluating the * corresponding expression in `items`. All items must have the same type. diff --git a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala index 813664931d..55d1575ff9 100644 --- a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala +++ b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala @@ -158,9 +158,6 @@ abstract class SigmaBuilder { def mkTaggedVariable[T <: SType](varId: Byte, tpe: T): TaggedVariable[T] - def mkSomeValue[T <: SType](x: Value[T]): Value[SOption[T]] - def mkNoneValue[T <: SType](elemType: T): Value[SOption[T]] - def mkBlock(bindings: Seq[Val], result: Value[SType]): Value[SType] def mkBlockValue(items: IndexedSeq[BlockItem], result: Value[SType]): Value[SType] def mkValUse(valId: Int, tpe: SType): Value[SType] @@ -527,11 +524,6 @@ class StdSigmaBuilder extends SigmaBuilder { override def mkTaggedVariable[T <: SType](varId: Byte, tpe: T): TaggedVariable[T] = TaggedVariableNode(varId, tpe).withSrcCtx(currentSrcCtx.value).asInstanceOf[TaggedVariable[T]] - override def mkSomeValue[T <: SType](x: Value[T]): Value[SOption[T]] = - SomeValue(x).withSrcCtx(currentSrcCtx.value) - override def mkNoneValue[T <: SType](elemType: T): Value[SOption[T]] = - NoneValue(elemType).withSrcCtx(currentSrcCtx.value) - override def mkBlock(bindings: Seq[Val], result: Value[SType]): Value[SType] = Block(bindings, result).withSrcCtx(currentSrcCtx.value) diff --git a/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala b/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala index 07616af0c4..f30b25b44c 100644 --- a/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala +++ b/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala @@ -48,7 +48,6 @@ class SigmaBinder(env: ScriptEnv, builder: SigmaBuilder, case "SELF" => Some(Self) case "CONTEXT" => Some(Context) case "Global" => Some(Global) - case "None" => Some(mkNoneValue(NoType)) case _ => None } } @@ -62,12 +61,6 @@ class SigmaBinder(env: ScriptEnv, builder: SigmaBuilder, val tpe = if (args.isEmpty) NoType else args(0).tpe Some(mkConcreteCollection(args, tpe)) - // Rule: Some(x) --> - case Apply(i @ Ident("Some", _), args) => args match { - case Seq(arg) => Some(mkSomeValue(arg)) - case _ => error(s"Invalid arguments of Some: expected one argument but found $args", i.sourceContext) - } - // Rule: min(x, y) --> case Apply(i @ Ident("min", _), args) => args match { case Seq(l: SValue, r: SValue) => diff --git a/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala b/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala index ad4dddcf51..ccc0784abe 100644 --- a/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala +++ b/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala @@ -497,9 +497,6 @@ class SigmaTyper(val builder: SigmaBuilder, case Negation(i) => unmap[SNumericType](env, "-", i.asNumValue)(mkNegation)(tT) case BitInversion(i) => unmap[SNumericType](env, "~", i.asNumValue)(mkBitInversion)(tT) - case SomeValue(x) => SomeValue(assignType(env, x)) - case v: NoneValue[_] => v - case Global => Global case Context => Context case Height => Height diff --git a/sc/shared/src/test/scala/sigmastate/lang/SigmaBinderTest.scala b/sc/shared/src/test/scala/sigmastate/lang/SigmaBinderTest.scala index a14aaf1c17..397c5c5e5d 100644 --- a/sc/shared/src/test/scala/sigmastate/lang/SigmaBinderTest.scala +++ b/sc/shared/src/test/scala/sigmastate/lang/SigmaBinderTest.scala @@ -143,19 +143,6 @@ class SigmaBinderTest extends AnyPropSpec with ScalaCheckPropertyChecks with Mat If(EQ(IntConstant(10), IntConstant(11)), IntConstant(2), IntConstant(3))) } - // TODO v5.x (4h): SomeValue and NoneValue are not used in ErgoTree and can be - // either removed or implemented in v4.x - property("Option constructors") { - bind(env, "None") shouldBe NoneValue(NoType) - bind(env, "Some(None)") shouldBe SomeValue(NoneValue(NoType)) - bind(env, "Some(10)") shouldBe SomeValue(IntConstant(10)) - bind(env, "Some(X)") shouldBe SomeValue(Ident("X")) - bind(env, "Some(Some(X - 1))") shouldBe - SomeValue(SomeValue(mkMinus(Ident("X").asValue[SInt.type], IntConstant(1)))) - bind(env, "Some(Some(X + 1))") shouldBe - SomeValue(SomeValue(plus(Ident("X").asValue[SInt.type], IntConstant(1)))) - } - property("lambdas") { bind(env, "{ (a: Int) => a - 1 }") shouldBe Lambda(IndexedSeq("a" -> SInt), NoType, mkMinus(IntIdent("a"), 1)) @@ -214,8 +201,4 @@ class SigmaBinderTest extends AnyPropSpec with ScalaCheckPropertyChecks with Mat e.source shouldBe Some(SourceContext(2, 5, "val x = 10")) } - property("fail Some (invalid arguments)") { - fail(env, "Some(1, 2)", 1, 1) - fail(env, "Some()", 1, 1) - } } diff --git a/sc/shared/src/test/scala/sigmastate/lang/SigmaCompilerTest.scala b/sc/shared/src/test/scala/sigmastate/lang/SigmaCompilerTest.scala index 73a424c456..f6266cf285 100644 --- a/sc/shared/src/test/scala/sigmastate/lang/SigmaCompilerTest.scala +++ b/sc/shared/src/test/scala/sigmastate/lang/SigmaCompilerTest.scala @@ -320,11 +320,6 @@ class SigmaCompilerTest extends CompilerTestingCommons with LangTests with Objec ) } - property("failed option constructors (not supported)") { - costerFail("None", 1, 1) - costerFail("Some(10)", 1, 1) - } - property("byteArrayToLong") { comp("byteArrayToLong(longToByteArray(1L))") shouldBe ByteArrayToLong(LongToByteArray(LongConstant(1))) } diff --git a/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala b/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala index 22c2a1fd7a..85476c3c6d 100644 --- a/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala +++ b/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala @@ -214,13 +214,6 @@ class SigmaTyperTest extends AnyPropSpec typefail(env, "Coll(1, false)", 1, 1) } - property("Option constructors") { - typecheck(env, "Some(10)") shouldBe SOption(SInt) - typecheck(env, "Some(x)") shouldBe SOption(SInt) - typecheck(env, "Some(x + 1)") shouldBe SOption(SInt) - typecheck(env, "Some(Some(10))") shouldBe SOption(SOption(SInt)) - } - property("methods returning Option") { typecheck(env, "getVar[Int](10)") shouldBe SOption(SInt) typecheck(env, "{ val v = getVar[Int](1); v.get }") shouldBe SInt