From 53394842850906ce20ee43c3594cc1117126b48a Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Wed, 12 Jun 2024 16:04:50 +0200 Subject: [PATCH] shouldCreateClosureRootNode when valueHasSomeTypeCheck (#10262) Fixes #10236. --- .../enso/interpreter/runtime/IrToTruffle.scala | 9 ++++++--- .../Base_Tests/src/Semantic/Conversion_Spec.enso | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/engine/runtime/src/main/scala/org/enso/interpreter/runtime/IrToTruffle.scala b/engine/runtime/src/main/scala/org/enso/interpreter/runtime/IrToTruffle.scala index 9cf7ea48c79..c6f6af9fe84 100644 --- a/engine/runtime/src/main/scala/org/enso/interpreter/runtime/IrToTruffle.scala +++ b/engine/runtime/src/main/scala/org/enso/interpreter/runtime/IrToTruffle.scala @@ -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 } diff --git a/test/Base_Tests/src/Semantic/Conversion_Spec.enso b/test/Base_Tests/src/Semantic/Conversion_Spec.enso index be4b82cb280..7ec836d3984 100644 --- a/test/Base_Tests/src/Semantic/Conversion_Spec.enso +++ b/test/Base_Tests/src/Semantic/Conversion_Spec.enso @@ -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