-
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.
Summary: Some bug in our handling of locations in type tables violates an implicit condition on emitted ranges: pairwise, they should either be nested or disjoint. This causes the coverage implementation, which relies on that assumption to split ranges, not terminate on certain inputs. This diff doesn't fix the actual bug, but instead makes the coverage implementation more rubust. It also adds a case to the type normalizer to make declare modules not appear uncovered. Fixes #2366 Fixes #1962 Reviewed By: gabelevi Differential Revision: D3796024 fbshipit-source-id: 7e87b10bb4c57ecfa20255ff2e2509406c5db1be
- Loading branch information
1 parent
1ae591f
commit b70fc3d
Showing
9 changed files
with
128 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
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
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,7 @@ | ||
[ignore] | ||
|
||
[include] | ||
|
||
[libs] | ||
|
||
[options] |
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 @@ | ||
shell: test.sh |
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,38 @@ | ||
// check coverage of declare module | ||
|
||
declare module foo { | ||
} | ||
|
||
Covered: 100.00% (1 of 1 expressions) | ||
|
||
// This file triggers a violation of the "disjoint-or-nested ranges invariant" | ||
// that we implicitly assume in type-at-pos and coverage implementations. In | ||
// particular, when unchecked it causes a crash with coverage --color. | ||
|
||
declare module foo { | ||
} | ||
|
||
declare module bar { | ||
} | ||
|
||
// TODO | ||
|
||
Covered: 100.00% (2 of 2 expressions) | ||
|
||
// This file triggers a violation of the "disjoint-or-nested ranges invariant" | ||
// that we implicitly assume in type-at-pos and coverage implementations. In | ||
// particular, when unchecked it causes non-termination with coverage --color. | ||
|
||
declare module foo { | ||
} | ||
|
||
declare module bar { | ||
} | ||
|
||
// TODO | ||
|
||
declare class qux { | ||
} | ||
|
||
Covered: 100.00% (3 of 3 expressions) | ||
|
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,11 @@ | ||
// This file triggers a violation of the "disjoint-or-nested ranges invariant" | ||
// that we implicitly assume in type-at-pos and coverage implementations. In | ||
// particular, when unchecked it causes a crash with coverage --color. | ||
|
||
declare module foo { | ||
} | ||
|
||
declare module bar { | ||
} | ||
|
||
// TODO |
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,4 @@ | ||
// check coverage of declare module | ||
|
||
declare module foo { | ||
} |
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,14 @@ | ||
// This file triggers a violation of the "disjoint-or-nested ranges invariant" | ||
// that we implicitly assume in type-at-pos and coverage implementations. In | ||
// particular, when unchecked it causes non-termination with coverage --color. | ||
|
||
declare module foo { | ||
} | ||
|
||
declare module bar { | ||
} | ||
|
||
// TODO | ||
|
||
declare class qux { | ||
} |
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,12 @@ | ||
#!/bin/sh | ||
|
||
FLOW=$1 | ||
|
||
# coverage of declare module | ||
$FLOW coverage --color declare_module.js | ||
|
||
# should not crash | ||
$FLOW coverage --color crash.js | ||
|
||
# should terminate | ||
$FLOW coverage --color non-termination.js |