Skip to content

Commit 762e2f2

Browse files
committed
Remove default empty value from bare version of executeFromSelfReg. Update documentation to match.
1 parent 8eb10f3 commit 762e2f2

File tree

3 files changed

+4
-44
lines changed

3 files changed

+4
-44
lines changed

data/shared/src/main/scala/sigma/ast/SigmaPredef.scala

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -432,31 +432,16 @@ object SigmaPredef {
432432
throw new InvalidArguments(s"Invalid register specified $id")
433433
}
434434

435-
val d : Option[Value[rtpe.type]] = rtpe match {
436-
case SInt => Some(IntConstant(0).asValue)
437-
case SBoolean => Some(BooleanConstant(false).asValue)
438-
case SByte => Some(ByteConstant(0).asValue)
439-
case SLong => Some(LongConstant(0L).asValue)
440-
case SBigInt => Some(BigIntConstant(0).asValue)
441-
case SSigmaProp => Some(SigmaPropConstant(CSigmaProp(false)).asValue)
442-
case c: SCollection[a] =>
443-
implicit val elemRType: RType[a#WrappedType] = asType(stypeToRType(c.elemType))
444-
implicit val elemCT: ClassTag[a#WrappedType] = elemRType.classTag
445-
Some(CollectionConstant(Colls.fromArray(elemRType.emptyArray), c.elemType).asValue)
446-
case _ => None
447-
}
448-
449435
val r: RegisterId = org.ergoplatform.ErgoBox.registerByIndex(idx)
450-
mkDeserializeRegister[rtpe.type](r, rtpe, d)
436+
mkDeserializeRegister[rtpe.type](r, rtpe, None)
451437
}),
452438
OperationInfo(DeserializeRegister,
453439
"""Extracts SELF register as \lst{Coll[Byte]}, deserializes it to script
454440
| and then executes this script in the current context.
455441
| The original \lst{Coll[Byte]} of the script is available as \lst{SELF.getReg[Coll[Byte]](id)}.
456442
| Type parameter \lst{T} result type of the deserialized script.
457443
| Throws an exception if the actual script type doesn't conform to \lst{T}.
458-
| Returns a result of the script execution in the current context or an empty value
459-
| of type \lst{T} when the specified register is unavailable
444+
| Returns a result of the script execution in the current context
460445
""".stripMargin,
461446
Seq(ArgInfo("id", "identifier of the register")))
462447
)

docs/LangSpec.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,9 +1036,8 @@ def executeFromVar[T](id: Byte): T
10361036
*
10371037
* Extracts, deserializes and executes a script contained in the SELF register
10381038
* indicated by id. Returns the result of the script execution in the current context
1039-
* or and empty value, if the register is unavailable. An exception is thrown if the result
1040-
* type of the execution doesn't conform to the return type specified and if an invalid
1041-
* register is specified.
1039+
* An exception is thrown if the result type of the execution doesn't conform to the
1040+
* return type specified and if an invalid register is specified.
10421041
*
10431042
* @param id register id holding the serialized script to execute
10441043
* @tparam T expected type of the register and return type.

sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -355,30 +355,6 @@ class BasicOpsSpecification extends CompilerTestingCommons
355355
)
356356
}
357357

358-
property("executeFromSelfReg - ScriptReduction") {
359-
assertExceptionThrown(
360-
test("executeFromSelfReg", env, ext,
361-
"{ val ba = executeFromSelfReg[Coll[Byte]](4); ba.size == 2 }",
362-
null,
363-
true,
364-
additionalRegistersOpt = Some(Map())
365-
),
366-
e => {
367-
val r = rootCause(e)
368-
r.isInstanceOf[InterpreterException] && r.getMessage == "Script reduced to false"
369-
}
370-
)
371-
}
372-
373-
property("executeFromSelfReg - ForceDefault") {
374-
test("executeFromSelfReg", env, ext,
375-
"{ executeFromSelfReg[Int](4) == 0 }",
376-
null,
377-
true,
378-
additionalRegistersOpt = Some(Map())
379-
)
380-
}
381-
382358
property("executeFromSelfReg - InvalidRegister") {
383359
assertExceptionThrown(
384360
test("executeFromSelfReg", env, ext,

0 commit comments

Comments
 (0)