-
Notifications
You must be signed in to change notification settings - Fork 457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix tag function location on error #6816
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 7 additions & 0 deletions
7
jscomp/build_tests/super_errors/expected/unknown_tagged_template_function.res.expected
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 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/unknown_tagged_template_function.res[0m:[2m1:11-14[0m | ||
|
||
[1;31m1[0m [2m│[0m let res = [1;31mtagg[0m`| 5 × 10 = ${5} |` | ||
|
||
The value tagg can't be found |
1 change: 1 addition & 0 deletions
1
jscomp/build_tests/super_errors/fixtures/unknown_tagged_template_function.res
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 @@ | ||
let res = tagg`| 5 × 10 = ${5} |` |
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 |
---|---|---|
|
@@ -2286,7 +2286,6 @@ and parse_template_expr ?prefix p = | |
Some prefix | ||
| _ -> Some "js" | ||
in | ||
let start_pos = p.Parser.start_pos in | ||
|
||
let parse_parts p = | ||
let rec aux acc = | ||
|
@@ -2319,13 +2318,9 @@ and parse_template_expr ?prefix p = | |
let parts = parse_parts p in | ||
let strings = List.map fst parts in | ||
let values = Ext_list.filter_map parts snd in | ||
let end_pos = p.Parser.end_pos in | ||
|
||
let gen_tagged_template_call lident = | ||
let ident = | ||
Ast_helper.Exp.ident ~attrs:[] ~loc:Location.none | ||
(Location.mknoloc lident) | ||
in | ||
let gen_tagged_template_call (lident_loc : Longident.t Location.loc) = | ||
let ident = Ast_helper.Exp.ident ~attrs:[] ~loc:lident_loc.loc lident_loc in | ||
let strings_array = | ||
Ast_helper.Exp.array ~attrs:[] ~loc:Location.none strings | ||
in | ||
|
@@ -2334,7 +2329,7 @@ and parse_template_expr ?prefix p = | |
in | ||
Ast_helper.Exp.apply | ||
~attrs:[tagged_template_literal_attr] | ||
~loc:(mk_loc start_pos end_pos) ident | ||
~loc:lident_loc.loc ident | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the real fix is here |
||
[(Nolabel, strings_array); (Nolabel, values_array)] | ||
in | ||
|
||
|
@@ -2374,7 +2369,7 @@ and parse_template_expr ?prefix p = | |
match prefix with | ||
| Some {txt = Longident.Lident ("js" | "j" | "json"); _} | None -> | ||
gen_interpolated_string () | ||
| Some {txt = lident} -> gen_tagged_template_call lident | ||
| Some lident_loc -> gen_tagged_template_call lident_loc | ||
|
||
(* Overparse: let f = a : int => a + 1, is it (a : int) => or (a): int => | ||
* Also overparse constraints: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this didn't make any difference