-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[parser] forbid reserved types in
opaque type
Summary: `opaque type string = number` would overwrite the `string` builtin. reserved types should be disallowed. Reviewed By: samwgoldman Differential Revision: D6199767 fbshipit-source-id: f0f5bdf44d8cff0d444381747f0ebb5a94df3ffa
- Loading branch information
1 parent
831243f
commit 74189a0
Showing
5 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/parser/test/flow/types/opaque_aliases/invalid/reserved_type.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
opaque type string = number; |
34 changes: 34 additions & 0 deletions
34
src/parser/test/flow/types/opaque_aliases/invalid/reserved_type.tree.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"errors":[ | ||
{ | ||
"loc":{"source":null,"start":{"line":1,"column":12},"end":{"line":1,"column":18}}, | ||
"message":"Unexpected reserved type" | ||
} | ||
], | ||
"type":"Program", | ||
"loc":{"source":null,"start":{"line":1,"column":0},"end":{"line":1,"column":28}}, | ||
"range":[0,28], | ||
"body":[ | ||
{ | ||
"type":"OpaqueType", | ||
"loc":{"source":null,"start":{"line":1,"column":0},"end":{"line":1,"column":28}}, | ||
"range":[0,28], | ||
"id":{ | ||
"type":"Identifier", | ||
"loc":{"source":null,"start":{"line":1,"column":12},"end":{"line":1,"column":18}}, | ||
"range":[12,18], | ||
"name":"string", | ||
"typeAnnotation":null, | ||
"optional":false | ||
}, | ||
"typeParameters":null, | ||
"impltype":{ | ||
"type":"NumberTypeAnnotation", | ||
"loc":{"source":null,"start":{"line":1,"column":21},"end":{"line":1,"column":27}}, | ||
"range":[21,27] | ||
}, | ||
"supertype":null | ||
} | ||
], | ||
"comments":[] | ||
} |
1 change: 1 addition & 0 deletions
1
src/parser/test/flow/types/opaque_aliases/valid/reserved_value.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
opaque type switch = number; |
28 changes: 28 additions & 0 deletions
28
src/parser/test/flow/types/opaque_aliases/valid/reserved_value.tree.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"type":"Program", | ||
"loc":{"source":null,"start":{"line":1,"column":0},"end":{"line":1,"column":28}}, | ||
"range":[0,28], | ||
"body":[ | ||
{ | ||
"type":"OpaqueType", | ||
"loc":{"source":null,"start":{"line":1,"column":0},"end":{"line":1,"column":28}}, | ||
"range":[0,28], | ||
"id":{ | ||
"type":"Identifier", | ||
"loc":{"source":null,"start":{"line":1,"column":12},"end":{"line":1,"column":18}}, | ||
"range":[12,18], | ||
"name":"switch", | ||
"typeAnnotation":null, | ||
"optional":false | ||
}, | ||
"typeParameters":null, | ||
"impltype":{ | ||
"type":"NumberTypeAnnotation", | ||
"loc":{"source":null,"start":{"line":1,"column":21},"end":{"line":1,"column":27}}, | ||
"range":[21,27] | ||
}, | ||
"supertype":null | ||
} | ||
], | ||
"comments":[] | ||
} |