Skip to content

Commit

Permalink
[flow][get-def] Make unbound name jump to itself
Browse files Browse the repository at this point in the history
Reviewed By: gkz

Differential Revision: D68729616

fbshipit-source-id: 56fc9b539bf9ebf85e6bac636cd71bedc419f484
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Jan 27, 2025
1 parent ee306d3 commit b00f9c6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/get_def/getDef_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ let rec process_request ~loc_of_aloc ~cx ~is_legit_require ~ast ~typed_ast_opt ~
| None ->
(match Context.builtin_type_opt cx name with
| Some (def_loc, _) -> Ok (Nel.one (loc_of_aloc def_loc), Some name)
| None -> Error (name ^ " is an unbound variable")))
| None -> Ok (Nel.one loc, Some name)))
| _ :: _ :: _ -> Error "Scope builder found multiple matching identifiers")
| Get_def_request.(Member { prop_name = name; object_type = (_loc, t); force_instance }) ->
extract_member_def ~loc_of_aloc ~cx ~file_sig ~typed_ast_opt ~force_instance t name
Expand Down
5 changes: 5 additions & 0 deletions tests/get_def/get_def.exp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ Flags:
type_literals.js:7:11
Flags:

unbound.js:3:4
Flags:
unbound.js:3:2,3:4

utilities.js:5:8
Flags:
utilities.js:1:20,1:22
Expand Down Expand Up @@ -381,4 +385,5 @@ parse_error_component.js:3:26,3:28

parse_error_component.js:10:30
Flags:
parse_error_component.js:10:30,10:30

1 change: 1 addition & 0 deletions tests/get_def/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,6 @@ queries_in_file "get-def" "literals.js"
queries_in_file "get-def" "require.js"
queries_in_file "get-def" "imports_from_cjs.js"
queries_in_file "get-def" "type_literals.js"
queries_in_file "get-def" "unbound.js"
queries_in_file "get-def" "utilities.js"
queries_in_file "get-def" "parse_error_component.js"
4 changes: 4 additions & 0 deletions tests/get_def/unbound.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @flow

foo;
// ^

0 comments on commit b00f9c6

Please sign in to comment.