You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The core of it seems to be that the Demote type function causes an error (in this specific place _2d) when it's behind a type alias (here Sub), but it's fine when the type alias is inlined (as in _2c)
Sorry this is so long. I tried to minimize as much as I could, but without understanding what's really going on I couldn't get it reduced any further.
It's possible to fix by removing the Tuple1[t] case in Demote, but there are no Tuple1s involved in calls to Demote so I don't understand why that should impact it.
objectMeta:typeShape=String|TupletypeDemote[S<:Tuple]<:Shape=SmatchcaseTuple1[t] => t &ShapecaseTuple=>StypeIf[T<:Boolean, R1, R2] <:R1|R2=Tmatchcasetrue=>R1casefalse=>R2typeContains[T<:Tuple, X] <:Boolean=TmatchcaseX*: r =>truecase _ *: r =>Contains[r, X]
case _ =>falsetypeRemoveStrict[T<:Tuple, X] <:Tuple=Tmatchcase head *: tail => head matchcaseX=> tail
case _ => head *:RemoveStrict[tail, X]
typeWithoutStrict[T<:Tuple, T2<:Tuple] <:Tuple=T2matchcase head *: tail =>WithoutStrict[RemoveStrict[T, head], tail]
caseEmptyTuple=>T/** Removes all elems from ToReplace and replaces the first replaced elem with replacement */typeReplaceAllStrict[T<:Tuple, ToReplace<:Tuple, Replacement] <:Tuple=Tmatchcase head *: tail =>If[Contains[ToReplace, head],
Replacement*:WithoutStrict[tail, RemoveStrict[ToReplace, head]],
head *:ReplaceAllStrict[tail, ToReplace, Replacement]]
caseEmptyTuple=>TtypeSub[S<:Tuple, ToReplace<:Tuple, Replacement<:String] =Demote[ReplaceAllStrict[S, ToReplace, Replacement]]
objectFoo:importMeta._// val _0: Sub["batch" *: EmptyTuple, Int *: EmptyTuple, "batch"] = "batch"// val _1: Sub[("batch", "len"), ("batch", "len"), "batch"] = "batch"// val _2a: ReplaceAllStrict[("batch", "len", "embed"), "batch" *: EmptyTuple, "b"] = ("b", "len", "embed")typeS= ("batch", "len")
typeToReplace="batch"*:EmptyTupletypeReplacement="b"val_2b:ReplaceAllStrict[S, ToReplace, Replacement] = ("b", "len") // okval_2c:Demote[ReplaceAllStrict[S, ToReplace, Replacement]] = ("b", "len") // okval_2d:Sub[S, ToReplace, Replacement] = ("b", "len") // error, see below
Output
48|val_2d:Sub[S, ToReplace, Replacement] = ("b", "len")
|^^^^^^^^^^^^|Found: (String, String)
|Required:Meta.Sub[Foo.S, Foo.ToReplace, Foo.Replacement]
||Note: a matchtypecould not be fully reduced:
|| trying to reduce Meta.Sub[Foo.S, Foo.ToReplace, Foo.Replacement]
| trying to reduce Meta.Demote[Meta.ReplaceAllStrict[Foo.S, Foo.ToReplace, Foo.Replacement]]
| failed since selector Foo.Replacement*:|Meta.WithoutStrict[("len":String) *:EmptyTuple.type,
|Meta.RemoveStrict[Foo.ToReplace, ("batch":String)]
| ]
| does not matchcaseTuple1[t] => t &Meta.Shape| and cannot be shown to be disjoint from it either.
|Therefore, reduction cannot advance to the remaining case||caseTuple=>Meta.ReplaceAllStrict[Foo.S, Foo.ToReplace, Foo.Replacement]
Expectation
I would expect that type aliases should behave identically to the "inlining" of them
The text was updated successfully, but these errors were encountered:
Compiler version
3.0.2, 3.1.0-RC1
Minimized code
The core of it seems to be that the
Demote
type function causes an error (in this specific place_2d
) when it's behind a type alias (hereSub
), but it's fine when the type alias is inlined (as in_2c
)Sorry this is so long. I tried to minimize as much as I could, but without understanding what's really going on I couldn't get it reduced any further.
It's possible to fix by removing the
Tuple1[t]
case inDemote
, but there are no Tuple1s involved in calls to Demote so I don't understand why that should impact it.Output
Expectation
I would expect that type aliases should behave identically to the "inlining" of them
The text was updated successfully, but these errors were encountered: