shouldCreateClosureRootNode when valueHasSomeTypeCheck (#10262)

Fixes #10236.
This commit is contained in:
Jaroslav Tulach 2024-06-12 16:04:50 +02:00 committed by GitHub
parent 0e17beba73
commit 5339484285
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 3 deletions

View File

@ -2195,10 +2195,13 @@ class IrToTruffle(
)
.unsafeAs[AliasInfo.Scope.Child]
def valueHasSomeTypeCheck() =
value.getMetadata(TypeSignatures).isDefined
val shouldCreateClosureRootNode = value match {
case _: Name => false
case _: Literal.Text => false
case _: Literal.Number => false
case _: Name => valueHasSomeTypeCheck()
case _: Literal.Text => valueHasSomeTypeCheck()
case _: Literal.Number => valueHasSomeTypeCheck()
case _ => true
}

View File

@ -617,6 +617,22 @@ add_specs suite_builder =
r = [r1, r2]
r.to_text . should_contain "Foo.Value 4"
group_builder.specify "Convert and catch" <|
fn x = x+2
convert_and_catch x = case x of
_:Function ->Panic.catch Any (x:Baz) err->
[err, x]
_ -> x
r1 = convert_and_catch 10
r2 = convert_and_catch (..Value 13)
r3 = convert_and_catch fn
r1 . should_equal 10
r2 . should_equal (Baz.Value 13)
r3.to_text . should_contain "expected expression to be Baz, but got"
suite_builder.group "Polyglot Argument" group_builder->
f1 (x : DateTimeFormatter) = x.to_text
f2 (x : Text | DateTimeFormatter) = case x of