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

Implicitly imported trait and local class get mingled #830

Open
supercooldave opened this issue Jun 23, 2017 · 0 comments
Open

Implicitly imported trait and local class get mingled #830

supercooldave opened this issue Jun 23, 2017 · 0 comments
Labels

Comments

@supercooldave
Copy link

supercooldave commented Jun 23, 2017

In the following code, parts of definitions in locally defined class C.M get added into the implicitly imported trait A.M, resulting in undeclared identifier bugs in the generated C code.

Consider the following three classes.

A.enc:

module A

read trait M
end

B.enc:

module B
import A

class T : M
end

and C.enc:

import B

read class M
  def foo() : int
    10
  end
end

active class Main
  def main() : unit
    println("{}", (new M).foo())
  end
end

Trait A.M is not explicitly imported, so there seems to be no clash between it and C.M.

Compilation results in the following error when compiling the generated C:

McIlroy:BuggyVersion dave$ ../../../../release/encorec C.enc 
C_src/T.encore.c:8:10: error: use of undeclared identifier '_ENC__MSG__A_M_foo';
      did you mean '_ENC__FUT_MSG__C_M_foo'?
    case _ENC__MSG__A_M_foo:
         ^~~~~~~~~~~~~~~~~~
         _ENC__FUT_MSG__C_M_foo
C_src/header.h:256:3: note: '_ENC__FUT_MSG__C_M_foo' declared here
  _ENC__FUT_MSG__C_M_foo,
  ^
C_src/T.encore.c:10:14: error: use of undeclared identifier
      '_enc__method__B_T_foo'; did you mean '_enc__method__C_M_foo'?
      return _enc__method__B_T_foo;
             ^~~~~~~~~~~~~~~~~~~~~
             _enc__method__C_M_foo
C_src/header.h:1304:9: note: '_enc__method__C_M_foo' declared here
int64_t _enc__method__C_M_foo(pony_ctx_t**, _enc__class__C_M_t*, pony_type_t**);
        ^
C_src/T.encore.c:13:10: error: use of undeclared identifier
      '_ENC__MSG__A_M_init'; did you mean '_ENC__FUT_MSG__C_M_init'?
    case _ENC__MSG__A_M_init:
         ^~~~~~~~~~~~~~~~~~~
         _ENC__FUT_MSG__C_M_init
C_src/header.h:257:3: note: '_ENC__FUT_MSG__C_M_init' declared here
  _ENC__FUT_MSG__C_M_init,
  ^
3 errors generated.
 *** Compilation failed with exit code 1 ***

What this means is that (part of) the definitions in C.M, namely the presence of an init method and a foo method, were added into the dispatch function for trait A.M, but no such methods exist for A.M.

A straightforward workaround is to rename one of the Ms.

This problem occurs in development.

@supercooldave supercooldave changed the title Implicitly imported trait and local class get mangled Implicitly imported trait and local class get mingled Jun 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant