Undecidable type inference crashes compilation #108

Closed
opened 2019-07-22 21:25:05 +09:00 by zxq9 · 1 comment
zxq9 commented 2019-07-22 21:25:05 +09:00 (Migrated from gitlab.com)

Created by: radrow

Compiling following code

contract Bum =
  stateful entrypoint bum() =
    Oracle.register(Contract.address, 12345, RelativeTTL(1000))
    ()

leads to internal compiler error ({badmatch,undefined}), however

contract Bum =
  stateful entrypoint bum() =
    Oracle.register(Contract.address, 12345, RelativeTTL(1000)) : oracle(int, int)
    ()

works flawlessly.

The type infer cannot deduce return type of Oracle.register... because it is polymorphic and does not depend on the context. This causes oracle type to be specified by an unbound typevar which makes compiler mad. Inferred return type of Oracle.register is exactly

{app_t,
         [{origin,system}],
         {id,[{origin,system}],"oracle"},
         [{tvar,[{file,"xd"},{line,3},{col,5}],"'a"},
          {tvar,[{file,"xd"},{line,3},{col,5}],"'b"}]}}

We should detect such situations and raise type errors.

Bug copyright (c) @hanssv

*Created by: radrow* Compiling following code ``` contract Bum = stateful entrypoint bum() = Oracle.register(Contract.address, 12345, RelativeTTL(1000)) () ``` leads to internal compiler error (`{badmatch,undefined}`), however ``` contract Bum = stateful entrypoint bum() = Oracle.register(Contract.address, 12345, RelativeTTL(1000)) : oracle(int, int) () ``` works flawlessly. The type infer cannot deduce return type of `Oracle.register...` because it is polymorphic and does not depend on the context. This causes oracle type to be specified by an unbound typevar which makes compiler mad. Inferred return type of `Oracle.register` is exactly ``` {app_t, [{origin,system}], {id,[{origin,system}],"oracle"}, [{tvar,[{file,"xd"},{line,3},{col,5}],"'a"}, {tvar,[{file,"xd"},{line,3},{col,5}],"'b"}]}} ``` We should detect such situations and raise type errors. Bug copyright (c) @hanssv
zxq9 commented 2019-10-04 18:22:02 +09:00 (Migrated from gitlab.com)

Created by: hanssv

This is fixed already.

*Created by: hanssv* This is fixed already.
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#108
No description provided.