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

[Typechecker] Missing typechecker error when redeclared properties in traits with stricter accessibility modifiers #8636

Open
lexidor opened this issue Jan 1, 2020 · 2 comments
Labels

Comments

@lexidor
Copy link
Collaborator

lexidor commented Jan 1, 2020

HHVM Version

HipHop VM 4.38.0-dev (rel)
Compiler: 1577504418_723705903
Repo schema: c0008085502abfa268d64b7193673709d52f0a0c
hackc-cc9cfe59f273bf16e25b5f524e7c7f044851ec5d-4.38.0-dev

Operating System and Version

Ubuntu 18.04

Standalone code, or other way to reproduce the problem

class SailPrivateUseProtected {
  use RedeclareSailProtected;
  private null $sail; // << Typing[4113] This member visibility is: private
}
class SailPrivateUsePublic {
  use RedeclareSailPublic;
  private null $sail; // << Typing[4113] This member visibility is: private
}

class SailProtectedUsePrivate {
  use RedeclareSailPrivate;
  protected null $sail; // << Only fails at runtime
}
class SailProtectedUsePublic {
  use RedeclareSailPublic;
  protected null $sail; // << Typing[4113] This member visibility is: protected
}

class SailPublicUsePrivate {
  use RedeclareSailPrivate;
  public null $sail; // << Only fails at runtime
}
class SailPublicUsePublic {
  use RedeclareSailProtected;
  public null $sail; // << Only fails at runtime
}

trait RedeclareSailPrivate {
  private null $sail;
}
trait RedeclareSailProtected {
  protected null $sail;
}
trait RedeclareSailPublic {
  public null $sail;
}

Actual result

Typing[4113] This member visibility is: private
   --> file.hack
  3 |   private null $sail; // << Typing[4113] This member visibility is: private
    |           ^^^^
 32 |   protected null $sail;
    |             ^^^^ protected was expected

Typing[4113] This member visibility is: private
   --> file.hack
  7 |   private null $sail; // << Typing[4113] This member visibility is: private
    |           ^^^^
 35 |   public null $sail;
    |          ^^^^ public was expected

Typing[4113] This member visibility is: protected
   --> file.hack
 16 |   protected null $sail; // << Typing[4113] This member visibility is: protected
    |             ^^^^
 35 |   public null $sail;
    |          ^^^^ public was expected

3 errors found.

Expected result

All of these cases should generate an error, since they all fail at runtime with an error like:

Fatal error: Uncaught Error: trait declaration of property 'sail' is incompatible with previous declaration in file.hack:line
@lexidor
Copy link
Collaborator Author

lexidor commented Jan 1, 2020

The code that generates this error message can be found here.

@lexidor lexidor changed the title [Typechecker] Missing typechecker error when properties in traits with stricter accessibility modifiers [Typechecker] Missing typechecker error when redeclared properties in traits with stricter accessibility modifiers Jan 2, 2020
@Wilfred Wilfred added the hack label Jan 31, 2020
@Wilfred
Copy link
Contributor

Wilfred commented Jan 31, 2020

@francesco-zappa-nardelli this might be interesting to you.

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

2 participants