No distinction between function definition and function call in lookup_env #395

Open
opened 2022-06-26 05:35:45 +09:00 by ghallak · 0 comments
ghallak commented 2022-06-26 05:35:45 +09:00 (Migrated from gitlab.com)
contract interface NameClashInterface =
  entrypoint double_proto : () => int
  entrypoint double_proto : () => int

contract C = entrypoint init() = ()

The above code will unexpectedly result in the following error:

{error,[{err,{pos,no_file,0,0},
             type_error,
             "Invalid call to contract entrypoint `NameClashInterface.double_proto`.",
             "It must be called as `c.double_proto` for some `c : NameClashInterface`."},

This happens because the lookup in the function lookup_env1 does not distinguish between a call to a qualified function and a new definition of a function in the scope, and it considers both as a call to a qualified function.

``` contract interface NameClashInterface = entrypoint double_proto : () => int entrypoint double_proto : () => int contract C = entrypoint init() = () ``` The above code will unexpectedly result in the following error: ``` {error,[{err,{pos,no_file,0,0}, type_error, "Invalid call to contract entrypoint `NameClashInterface.double_proto`.", "It must be called as `c.double_proto` for some `c : NameClashInterface`."}, ``` This happens because the lookup in the function [`lookup_env1`](https://github.com/aeternity/aesophia/blob/7b8957b46af059ab6c24d0675ff8c351da3d60d2/src/aeso_ast_infer_types.erl#L415-L434) does not distinguish between a call to a qualified function and a new definition of a function in the scope, and it considers both as a call to a qualified function.
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#395
No description provided.