-
Notifications
You must be signed in to change notification settings - Fork 469
Compiler@master sometimes reports module name instead of source file as error location #5635
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
Comments
Can you share the code for me to reproduce? |
Here: module Foo = {
let compare = (nextProps, currentProps) => nextProps["foo"] == currentProps["foo"]
let memo = React.memoCustomCompareProps(_, compare)
@react.component
let make = memo((~foo: string) => React.string(foo))
}
|
@mattdamon108 looks like a source location issue (e.g. loc_none is used) |
Source: module React = {
type element
external string: string => element = "%identity"
}
module Foo = {
@react.component
let make = (~s) => React.string(s)
} Debug command: % ~/GitHub/rescript-compiler/bsc -dtypedtree -bs-loc -bs-jsx 4 src/Cmp.res
[
structure_item (src/Cmp.res[1,0+0]..src/Cmp.res[4,83+1])
Tstr_module
React/1002
module_expr (src/Cmp.res[1,0+15]..src/Cmp.res[4,83+1])
Tmod_structure
[
structure_item (src/Cmp.res[2,17+2]..src/Cmp.res[2,17+14])
Tstr_type Nonrec
[
type_declaration element/1003 (src/Cmp.res[2,17+2]..src/Cmp.res[2,17+14])
ptype_params =
[]
ptype_cstrs =
[]
ptype_kind =
Ttype_abstract
ptype_private = Public
ptype_manifest =
None
]
structure_item (src/Cmp.res[3,32+2]..src/Cmp.res[3,32+50])
Tstr_primitive
value_description string/1004 (src/Cmp.res[3,32+2]..src/Cmp.res[3,32+50])
core_type (src/Cmp.res[3,32+19]..src/Cmp.res[3,32+36])
Ttyp_arrow
Nolabel
core_type (src/Cmp.res[3,32+19]..src/Cmp.res[3,32+25])
Ttyp_constr "string/13"
[]
core_type (src/Cmp.res[3,32+29]..src/Cmp.res[3,32+36])
Ttyp_constr "element/1003"
[]
[
"%identity"
]
]
structure_item (src/Cmp.res[6,86+0]..src/Cmp.res[9,157+1])
Tstr_module
Foo/1005
module_expr (src/Cmp.res[6,86+13]..src/Cmp.res[9,157+1])
module_expr (src/Cmp.res[6,86+13]..src/Cmp.res[9,157+1])
Tmod_structure
[
structure_item (_none_[1,0+-1].._none_[1,0+-1]) ghost
Tstr_type Nonrec
[
type_declaration props/1006 (Cmp[1,0+-1]..Cmp[1,0+-1]) ghost
ptype_params =
[
core_type (_none_[1,0+-1].._none_[1,0+-1]) ghost
Ttyp_var s
]
ptype_cstrs =
[]
ptype_kind =
Ttype_record
[
(Cmp[1,0+-1]..Cmp[1,0+-1]) ghost
attribute "ns.optional"
[]
Immutable
key/1007 core_type (Cmp[1,0+-1]..Cmp[1,0+-1]) ghost
Ttyp_poly
core_type (Cmp[1,0+-1]..Cmp[1,0+-1]) ghost
Ttyp_constr "option/10"
[
core_type (Cmp[1,0+-1]..Cmp[1,0+-1]) ghost
Ttyp_constr "string/13"
[]
]
(Cmp[1,0+-1]..Cmp[1,0+-1]) ghost
Immutable
s/1008 core_type (_none_[1,0+-1].._none_[1,0+-1]) ghost
Ttyp_poly
core_type (_none_[1,0+-1].._none_[1,0+-1]) ghost
Ttyp_var s
]
ptype_private = Public
ptype_manifest =
None
]
structure_item (src/Cmp.res[7,101+2]..src/Cmp.res[8,120+36])
Tstr_value Nonrec
[
<def>
attribute "react.component"
[]
pattern (_none_[1,0+-1].._none_[1,0+-1]) ghost
Tpat_var "make/1009"
expression (_none_[1,0+-1].._none_[1,0+-1]) ghost
Texp_function
param/1011 Nolabel
[
<case>
pattern (_none_[1,0+-1].._none_[1,0+-1]) ghost
Tpat_constraint
core_type (Cmp[1,0+-1]..Cmp[1,0+-1]) ghost
Ttyp_constr "props/1006"
[
core_type (src/Cmp.res[8,120+14]..src/Cmp.res[8,120+16])
Ttyp_var s
]
pattern (_none_[1,0+-1].._none_[1,0+-1]) ghost
Tpat_record
[
"s"
pattern (src/Cmp.res[8,120+14]..src/Cmp.res[8,120+16])
attribute "ns.namedArgLoc"
[]
Tpat_var "s/1010"
]
expression (src/Cmp.res[8,120+21]..src/Cmp.res[8,120+36])
Texp_apply
expression (src/Cmp.res[8,120+21]..src/Cmp.res[8,120+33])
Texp_ident "React/1002.string"
[
<arg>
Nolabel
expression (src/Cmp.res[8,120+34]..src/Cmp.res[8,120+35])
Texp_ident "s/1010"
]
]
]
structure_item (Cmp[1,0+-1]..Cmp[1,0+-1]) ghost
Tstr_value Nonrec
[
<def>
pattern (src/Cmp.res[8,120+6]..src/Cmp.res[8,120+10])
Tpat_var "make/1012"
expression (_none_[1,0+-1].._none_[1,0+-1]) ghost
Texp_let Nonrec
[
<def>
pattern (Cmp[1,0+-1]..Cmp[1,0+-1]) ghost
Tpat_var "Cmp$Foo/1013"
expression (_none_[1,0+-1].._none_[1,0+-1]) ghost
Texp_function
props/1014 Nolabel
[
<case>
pattern (_none_[1,0+-1].._none_[1,0+-1]) ghost
Tpat_constraint
core_type (_none_[1,0+-1].._none_[1,0+-1]) ghost
Ttyp_constr "props/1006"
[
core_type (_none_[1,0+-1].._none_[1,0+-1]) ghost
Ttyp_any
]
pattern (_none_[1,0+-1].._none_[1,0+-1]) ghost
Tpat_alias "props/1014"
pattern (_none_[1,0+-1].._none_[1,0+-1]) ghost
Tpat_any
expression (_none_[1,0+-1].._none_[1,0+-1]) ghost
Texp_apply
expression (_none_[1,0+-1].._none_[1,0+-1]) ghost
Texp_ident "make/1009"
[
<arg>
Nolabel
expression (_none_[1,0+-1].._none_[1,0+-1]) ghost
Texp_ident "props/1014"
]
]
]
expression (Cmp[1,0+-1]..Cmp[1,0+-1]) ghost
Texp_ident "Cmp$Foo/1013"
]
]
]
// Generated by ReScript, PLEASE EDIT WITH CARE
'use strict';
var React = {};
function Cmp$Foo(props) {
return props.s;
}
var Foo = {
make: Cmp$Foo
};
exports.React = React;
exports.Foo = Foo;
/* No side effect */ |
So the entire definition of type |
I didn't grab the time to look into it yet.
|
Yeap, I'll fix it to use the same location of
|
I did quick fix yesterday to add the same location of |
Perhaps the body of the function? |
Sure thing. I’ll put dummy locs to possible points to explore the better location. |
Fixed rescript-lang/syntax#633 |
Context: trying out JSX v4
The
SpotDetails
belowWe've found a bug for you!
should be/absolute/path/to/Source.res:line:char-char
instead of a module name.The VSCode extension tries to open a nonexistent directory when you click the Problem:


This does not happen with all errors; some report a correct location.
The text was updated successfully, but these errors were encountered: