Skip to content

Commit

Permalink
[lti][soundness] Rollback cache after synthesis mode
Browse files Browse the repository at this point in the history
Summary:
The cache was properly rolled back before, but it was dropped by mistake in D41361086 (f05653c).

Close #9007

Changelog: [errors] Some additional errors might be revealed after a correctness fix in implicit instantiation. Example: https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVBLAtgBzgJwBcwAlAUwEMBjYqfOLMAcn0pqYG5UoBXAOxoY4fMAGEGePmT6EAPABUAXGD48 (114c051e26016bfbd117d80634e48c55442fdf2f)sAIzL4AfAAocOejgDOygN4VF8gL4BKZeWqEAJADk4AEzJgz19MGAwKAoMGFRZDwwAN21ZcVxhaWIKAF4zQnweMmswYFjgSJiuIA

Reviewed By: panagosg7

Differential Revision: D43207712

fbshipit-source-id: 0b3d3f5c6e3f938abe777781686b8717fc3019dc
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Feb 13, 2023
1 parent 8b2f452 commit 048b477
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/typing/context.ml
Expand Up @@ -906,7 +906,9 @@ let run_in_synthesis_mode cx f =
cx.ccx.speculation_state := [];
cx.ccx.produced_placeholders <- false;
cx.in_synthesis_mode <- true;
let cache_snapshot = take_cache_snapshot cx in
let result = Base.Result.try_with f in
restore_cache_snapshot cx cache_snapshot;
cx.ccx.speculation_state := saved_speculation_state;
cx.in_synthesis_mode <- old_synthesis_mode;
let produced_placeholders = cx.ccx.produced_placeholders in
Expand Down
3 changes: 3 additions & 0 deletions tests/post_inference_implicit_instantiation/contextual_jsx.js
Expand Up @@ -13,3 +13,6 @@ const z = (
<Component />
</Wrapper>
);

function ComponentWithBound<T: number>(pprops: {a:T}): React$Node {}
<div><ComponentWithBound a={true} /></div>; // error: bool ~> number
Expand Up @@ -34,6 +34,21 @@ References:
^^^^^^^^^^^^^ [2]


Error ------------------------------------------------------------------------------------------ contextual_jsx.js:18:29

Cannot create `ComponentWithBound` element because boolean [1] is incompatible with number [2] in type argument `T`.
[incompatible-type-arg]

contextual_jsx.js:18:29
18| <div><ComponentWithBound a={true} /></div>; // error: bool ~> number
^^^^ [1]

References:
contextual_jsx.js:17:32
17| function ComponentWithBound<T: number>(pprops: {a:T}): React$Node {}
^^^^^^ [2]


Error --------------------------------------------------------------------------------------------------- invalid.js:5:8

Cannot call `Import.store` because `store` [1] is not a function. [not-a-function]
Expand Down Expand Up @@ -579,4 +594,4 @@ References:



Found 34 errors
Found 35 errors
Expand Up @@ -49,6 +49,21 @@ References:
^^^^^^^^^^^^^ [2]


Error ------------------------------------------------------------------------------------------ contextual_jsx.js:18:29

Cannot create `ComponentWithBound` element because boolean [1] is incompatible with number [2] in type argument `T`.
[incompatible-type-arg]

contextual_jsx.js:18:29
18| <div><ComponentWithBound a={true} /></div>; // error: bool ~> number
^^^^ [1]

References:
contextual_jsx.js:17:32
17| function ComponentWithBound<T: number>(pprops: {a:T}): React$Node {}
^^^^^^ [2]


Error --------------------------------------------------------------------------------------------------- invalid.js:5:8

Cannot call `Import.store` because `store` [1] is not a function. [not-a-function]
Expand Down Expand Up @@ -963,4 +978,4 @@ References:



Found 62 errors
Found 63 errors

0 comments on commit 048b477

Please sign in to comment.