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:
parent
a5fcc3f1df
commit
9c887e7eee
@ -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 <>)
|
||||
|
@ -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;
|
||||
|
3
test/fixtures/typescript/analysis/access_control/private_static_field_definition.ts
vendored
Normal file
3
test/fixtures/typescript/analysis/access_control/private_static_field_definition.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { Adder } from "./adder"
|
||||
|
||||
Adder.z
|
Loading…
Reference in New Issue
Block a user