Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type checks inconsistent when dealing with a -> b function types #7289

Closed
radeusgd opened this issue Jul 13, 2023 · 4 comments · Fixed by #7298
Closed

Type checks inconsistent when dealing with a -> b function types #7289

radeusgd opened this issue Jul 13, 2023 · 4 comments · Fixed by #7298
Assignees
Labels

Comments

@radeusgd
Copy link
Member

from Standard.Base import all

t1 (f : Function) =
    f "x"

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

t3 (f : (Integer | Function)) =
    f "x"

t4 (f : (Integer | (Text -> Any))) =
    f "x"

main =
    f x = "|" + x + "|"
    IO.println (t1 f)
    IO.println (t2 f)
    IO.println (t3 f)
    IO.println (t4 f)

Running the example above yields:

|x|
|x|
|x|
Execution finished with an error: Type error: expected `f` to be Integer, but got Function.
        at <enso> inconsistent-function-type.t4(inconsistent-function-type.enso:12-13)
        at <enso> inconsistent-function-type.main<arg-1>(inconsistent-function-type.enso:20:17-20)
        at <enso> inconsistent-function-type.main(inconsistent-function-type.enso:20:5-21)

Whereas we'd expect all 4 cases to behave the same way.

Weirdly, if the type is 'alone' - both Function and Text -> Any behave the same and accept a function input.

However, once we construct a sum type using |, for some weird reason the Text -> Any seems as if it disappears.

@JaroslavTulach JaroslavTulach changed the title Type checks behave inconsistently when encountering a -> b function types Type checks inconsistent when dealding with a -> b function types Jul 13, 2023
@JaroslavTulach JaroslavTulach changed the title Type checks inconsistent when dealding with a -> b function types Type checks inconsistent when dealing with a -> b function types Jul 13, 2023
@JaroslavTulach JaroslavTulach linked a pull request Jul 15, 2023 that will close this issue
2 tasks
@JaroslavTulach
Copy link
Member

However, once we construct a sum type using |, for some weird reason the Text -> Any seems as if it disappears.

Text->Any actually disappears all the time. Just in case of t4 the Integer is left in the check. While in case of t2 there is no type check at all. Anyway #7298 fixes it all.

@enso-bot
Copy link

enso-bot bot commented Jul 16, 2023

Jaroslav Tulach reports a new STANDUP for yesterday (2023-07-15):

Progress: - fixes #7289 ready for review: #7298

Next Day: Bugfixes, cleanup & performance

@enso-bot
Copy link

enso-bot bot commented Jul 17, 2023

Jaroslav Tulach reports a new STANDUP for yesterday (2023-07-16):

Progress: - bugfix CompilationStage: https://github.com/enso-org/enso/compare/392a8135862c029e8ee3be72d75514980d4644d9..fd0a9e70a1bc1bbda03756395bd8a8f1250d0f38

  • hiding unsafe methods: c073c1b
  • Shuffling CompilerContext It should be finished by 2023-07-17.

Next Day: Bugfixes, cleanup & performance

GitHub
Hybrid visual and textual functional programming. Contribute to enso-org/enso development by creating an account on GitHub.

@enso-bot
Copy link

enso-bot bot commented Jul 18, 2023

Jaroslav Tulach reports a new STANDUP for yesterday (2023-07-17):

Progress: - bookclub on top of runProjectManagerDistribution: #7181 - integratd

Next Day: Bugfixes, cleanup & performance

Discord
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants