Typechecker does not warn about enforced monomorphism of local definitions #112

Closed
opened 2019-08-02 05:52:25 +09:00 by zxq9 · 1 comment
zxq9 commented 2019-08-02 05:52:25 +09:00 (Migrated from gitlab.com)

Created by: radrow

Following code does not typecheck:

  entrypoint tttt() =
    let f(x : 'a) : 'a = x
    if(f(true)) f(1) else f(2)

because local functions are not allowed to be polymorphic and 'a get implicitly assigned to bool which causes f(1) to be badly typed. This behavior is very misleading, because the actual type of f (bool => bool) does not match explicitly given type signature.
We should detect such situations and rise meaningful errors.

*Created by: radrow* Following code does not typecheck: ``` entrypoint tttt() = let f(x : 'a) : 'a = x if(f(true)) f(1) else f(2) ``` because local functions are not allowed to be polymorphic and `'a` get implicitly assigned to `bool` which causes `f(1)` to be badly typed. This behavior is very misleading, because the actual type of `f` (`bool => bool`) does not match explicitly given type signature. We should detect such situations and rise meaningful errors.
zxq9 commented 2019-08-30 20:55:16 +09:00 (Migrated from gitlab.com)

Created by: radrow

moved out

*Created by: radrow* moved out
Sign in to join this conversation.
No Milestone
No project
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: QPQ-AG/sophia#112
No description provided.