mirror of
https://github.com/fluencelabs/aqua.git
synced 2025-04-25 06:52:13 +00:00
fix(compiler): Fix CRDT Map in array handling [LNG-370] (#1171)
* Stricten CollectibleType * Add test * Add comment
This commit is contained in:
parent
af3fc24adb
commit
b0f3a8c21e
@ -1012,4 +1012,25 @@ class SemanticsSpec extends AnyFlatSpec with Matchers with Inside {
|
|||||||
atLeast(1, errors.toChain.toList) shouldBe a[RulesViolated[Span.S]]
|
atLeast(1, errors.toChain.toList) shouldBe a[RulesViolated[Span.S]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: This should be true until aqua has immutable map type
|
||||||
|
it should "prohibit putting stream maps into collection" in {
|
||||||
|
def test(prefix: String = "") = {
|
||||||
|
val script = s"""|func test(arr: []⊤) -> string:
|
||||||
|
| <- "test"
|
||||||
|
|
|
||||||
|
|func main() -> string:
|
||||||
|
| map: %string
|
||||||
|
| <- test(${prefix}[map])""".stripMargin
|
||||||
|
|
||||||
|
insideSemErrors(script) { errors =>
|
||||||
|
errors.collect { case RulesViolated(_, messages) => messages }.toList.flatten
|
||||||
|
.contains("Value of type '%string' could not be put into a collection") shouldBe (true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test()
|
||||||
|
test("?")
|
||||||
|
test("*")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,6 +330,7 @@ object CollectionType {
|
|||||||
sealed trait ImmutableCollectionType extends CollectionType with DataType {
|
sealed trait ImmutableCollectionType extends CollectionType with DataType {
|
||||||
def withElement(t: DataType): ImmutableCollectionType
|
def withElement(t: DataType): ImmutableCollectionType
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed trait MutableStreamType extends CollectionType {
|
sealed trait MutableStreamType extends CollectionType {
|
||||||
def toCanon: ImmutableCollectionType
|
def toCanon: ImmutableCollectionType
|
||||||
}
|
}
|
||||||
@ -389,7 +390,7 @@ case class StreamMapType(override val element: DataType) extends MutableStreamTy
|
|||||||
|
|
||||||
override def toString: String = s"%$element"
|
override def toString: String = s"%$element"
|
||||||
|
|
||||||
def getFunc(f: Func): ArrowType ={
|
def getFunc(f: Func): ArrowType = {
|
||||||
val (args, rets) = f match {
|
val (args, rets) = f match {
|
||||||
case Get =>
|
case Get =>
|
||||||
(ScalarType.string :: Nil) -> (ArrayType(element) :: Nil)
|
(ScalarType.string :: Nil) -> (ArrayType(element) :: Nil)
|
||||||
@ -602,9 +603,11 @@ case class ArrowType(domain: ProductType, codomain: ProductType) extends Type {
|
|||||||
object Type {
|
object Type {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `StreamType` is collectible with canonicalization
|
* `StreamType` is collectible with canonicalization.
|
||||||
|
* Note: until aqua type system has immutable maps,
|
||||||
|
* they are not collectible
|
||||||
*/
|
*/
|
||||||
type CollectibleType = DataType | MutableStreamType
|
type CollectibleType = DataType | StreamType
|
||||||
|
|
||||||
def isStreamType(t: Type): Boolean =
|
def isStreamType(t: Type): Boolean =
|
||||||
t match {
|
t match {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user