Skip to content

Commit

Permalink
IR.Type.Function is treated as Funtion builtin type
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Jul 15, 2023
1 parent e537766 commit 9f18057
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ class IrToTruffle(
def extractAscribedType(t: IR.Expression): List[Type] = t match {
case u: IR.Type.Set.Union => u.operands.flatMap(extractAscribedType)
case p: IR.Application.Prefix => extractAscribedType(p.function)
case _: IR.Type.Function =>
List(context.getTopScope().getBuiltins().function())
case t => {
t.getMetadata(TypeNames) match {
case Some(
Expand Down
20 changes: 10 additions & 10 deletions test/Tests/src/Runtime/Ascribed_Parameters_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import Standard.Test.Extensions
import Standard.Base.Errors.Common.Type_Error

spec = Test.group "Function Ascribed Parameters" <|
t1 (f : Function) =
f "x"
t1 (f1 : Function) =
f1 "x"

t2 (f : (Text -> Any)) =
f "x"
t2 (f2 : (Text -> Any)) =
f2 "x"

t3 (f : (Integer | Function)) = case f of
t3 (f3 : (Integer | Function)) = case f3 of
n : Integer -> n*7
_ -> f "x"
_ -> f3 "x"

t4 (f : (Integer | (Text -> Any))) = case f of
t4 (f4 : (Integer | (Text -> Any))) = case f4 of
n : Integer -> n*7
_ -> f "x"
_ -> f4 "x"

surround x = "|" + x + "|"

Expand All @@ -37,10 +37,10 @@ spec = Test.group "Function Ascribed Parameters" <|
(t4 surround) . should_equal "|x|"

Test.specify "t1 with 42 type check" <|
(t1 6) . should_equal "|x|"
with_type_error (t1 6) . should_fail_with Type_Error

Test.specify "t2 with 42 type check" <|
(t2 6) . should_equal "|x|"
with_type_error (t2 6) . should_fail_with Type_Error

Test.specify "t3 with 42 type check" <|
(t3 6) . should_equal 42
Expand Down

0 comments on commit 9f18057

Please sign in to comment.