1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Ensure private static field definitions are not accessible by external member access

This commit is contained in:
Rick Winfrey 2019-01-17 17:21:16 -08:00
parent a5fcc3f1df
commit 9c887e7eee
3 changed files with 11 additions and 0 deletions

View File

@ -169,6 +169,11 @@ spec config = parallel $ do
let expected = Left (SomeError (inject @(BaseError (EvalError (Quieterm (Sum TypeScript.Syntax) Location) Precise (Concrete.Value (Quieterm (Sum TypeScript.Syntax) Location) Precise))) (BaseError (ModuleInfo "private_field_definition.ts") (Span (Pos 4 1) (Pos 4 6)) (AccessControlError ("foo", ScopeGraph.Public) ("y", ScopeGraph.Private) (Concrete.Float (Decimal 2.0))))))
res `shouldBe` expected
it "member access of private static public field definition throws AccessControlError" $ do
(_, (_, res)) <- evaluate ["access_control/adder.ts", "access_control/private_static_field_definition.ts"]
let expected = Left (SomeError (inject @(BaseError (EvalError (Quieterm (Sum TypeScript.Syntax) Location) Precise (Concrete.Value (Quieterm (Sum TypeScript.Syntax) Location) Precise))) (BaseError (ModuleInfo "private_static_field_definition.ts") (Span (Pos 3 1) (Pos 3 8)) (AccessControlError ("Adder", ScopeGraph.Public) ("z", ScopeGraph.Private) Unit))))
res `shouldBe` expected
where
fixtures = "test/fixtures/typescript/analysis/"
evaluate = evalTypeScriptProject . map (fixtures <>)

View File

@ -1,6 +1,9 @@
class Adder {
public x: number;
private y: number;
public static w: number;
private static z: number;
constructor(x, y) {
this.x = x;

View File

@ -0,0 +1,3 @@
import { Adder } from "./adder"
Adder.z