Skip to content

Commit d833879

Browse files
cristianocjaredly
authored andcommitted
Fix issue where getting the ident binding time only works for 4.08. (#363)
* Fix issue where getting the ident binding time only works for 4.08. * Cosmetic: make the ident hack explicit so it's clear it only works for 408.
1 parent fcac32a commit d833879

File tree

12 files changed

+91
-91
lines changed

12 files changed

+91
-91
lines changed

core/Query.re

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ let findInScope = (pos, name, stamps) => {
4646

4747
let rec joinPaths = (modulePath, path) => {
4848
switch modulePath {
49-
| Path.Pident(ident) => (Current.ident_binding_time(ident), Ident.name(ident), path)
49+
| Path.Pident(ident) => (Current.ident_binding_time_408(ident), Ident.name(ident), path)
5050
| Path.Papply(fnPath, _argPath) => joinPaths(fnPath, path)
5151
| Path.Pdot(inner, name) => joinPaths(inner, Nested(name, path))
5252
}
5353
};
5454

5555
let rec makePath = (modulePath) => {
5656
switch modulePath {
57-
| Path.Pident(ident) when Current.ident_binding_time(ident) === 0 =>
57+
| Path.Pident(ident) when Current.ident_binding_time_408(ident) === 0 =>
5858
`GlobalMod(Ident.name(ident))
59-
| Path.Pident(ident) => `Stamp(Current.ident_binding_time(ident))
59+
| Path.Pident(ident) => `Stamp(Current.ident_binding_time_408(ident))
6060
| Path.Papply(fnPath, _argPath) => makePath(fnPath)
6161
| Path.Pdot(inner, name) => `Path(joinPaths(inner, Tip(name)))
6262
}

ocaml_typing/current/Current.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ type longident = Longident.t =
1414

1515
type abstract_ident = Ident.t
1616

17-
type ident =
17+
type ident_408 =
1818
| Local of { name: string; stamp: int }
1919
| Scoped of { name: string; stamp: int; scope: int }
2020
| Global of string
2121
| Predef of { name: string; stamp: int }
2222

23-
let ident_binding_time ident =
24-
let current_ident = (Obj.magic ident : ident) in
23+
let ident_binding_time_408 (ident: Ident.t) =
24+
let current_ident = (Obj.magic ident : ident_408) in
2525
match current_ident with
2626
| Predef { stamp }
2727
| Scoped { stamp }

process_ocaml/402/ProcessCmt.re

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ let rec forSignatureTypeItem = (env, exported: SharedTypes.Module.exported, item
107107
let declared = addItem(
108108
~name=Location.mknoloc(Ident.name(ident)),
109109
~extent=loc,
110-
~stamp=Current.ident_binding_time(ident),
110+
~stamp=Ident.binding_time(ident),
111111
~env,
112112
~contents,
113113
val_attributes,
@@ -139,7 +139,7 @@ let rec forSignatureTypeItem = (env, exported: SharedTypes.Module.exported, item
139139
| Type_variant(constructors) => {
140140
Variant(constructors |. Belt.List.map(({cd_loc, cd_id, cd_args, cd_res, cd_attributes}) => {
141141
let name = Ident.name(cd_id);
142-
let stamp = Current.ident_binding_time(cd_id);
142+
let stamp = Ident.binding_time(cd_id);
143143
let contents = {
144144
Type.Constructor.stamp,
145145
name: Location.mknoloc(name),
@@ -169,13 +169,13 @@ let rec forSignatureTypeItem = (env, exported: SharedTypes.Module.exported, item
169169
}
170170
| Type_record(labels, _) => Record(labels |> List.map(
171171
({ld_id, ld_type}) => {
172-
let astamp = Current.ident_binding_time(ld_id);
172+
let astamp = Ident.binding_time(ld_id);
173173
let name = Ident.name(ld_id);
174174
{Type.Attribute.stamp: astamp, name: Location.mknoloc(name), typ: Shared.makeFlexible(ld_type), typLoc: Location.none}
175175
}
176176
))
177177
}
178-
}, ~name=Location.mknoloc(Ident.name(ident)), ~stamp=Current.ident_binding_time(ident), ~env, type_attributes, exported.types, env.stamps.types);
178+
}, ~name=Location.mknoloc(Ident.name(ident)), ~stamp=Ident.binding_time(ident), ~env, type_attributes, exported.types, env.stamps.types);
179179
[{...declared, contents: Module.Type(declared.contents)}]
180180
}
181181
/* | Sig_module({stamp, name}, {md_type: Mty_ident(path) | Mty_alias(path), md_attributes, md_loc}, _) =>
@@ -190,7 +190,7 @@ let rec forSignatureTypeItem = (env, exported: SharedTypes.Module.exported, item
190190
~extent=md_loc,
191191
~contents=forModuleType(env, md_type),
192192
~name=Location.mknoloc(Ident.name(ident)),
193-
~stamp=Current.ident_binding_time(ident),
193+
~stamp=Ident.binding_time(ident),
194194
~env,
195195
md_attributes,
196196
exported.modules,
@@ -227,7 +227,7 @@ let getModuleTypePath = (mod_desc) => switch mod_desc {
227227
};
228228

229229
let forTypeDeclaration = (~env, ~exported: Module.exported, {typ_id, typ_loc, typ_params, typ_name: name, typ_attributes, typ_type, typ_kind, typ_manifest}) => {
230-
let stamp = Current.ident_binding_time(typ_id);
230+
let stamp = Ident.binding_time(typ_id);
231231
let declared = addItem(~extent=typ_loc, ~contents={
232232
Type.params: typ_params |> List.map(((t, _)) => (Shared.makeFlexible(t.ctyp_type), t.ctyp_loc)),
233233
typ: Shared.makeDeclaration(typ_type),
@@ -244,7 +244,7 @@ let forTypeDeclaration = (~env, ~exported: Module.exported, {typ_id, typ_loc, ty
244244
}
245245
| Ttype_open => Open
246246
| Ttype_variant(constructors) => Variant(constructors |> List.map(({cd_id, cd_name: name, cd_args, cd_res}) => {
247-
let stamp = Current.ident_binding_time(cd_id);
247+
let stamp = Ident.binding_time(cd_id);
248248
{
249249
Type.Constructor.stamp,
250250
name,
@@ -254,7 +254,7 @@ let forTypeDeclaration = (~env, ~exported: Module.exported, {typ_id, typ_loc, ty
254254
}}))
255255
| Ttype_record(labels) => Record(labels |> List.map(
256256
({ld_id, ld_name: name, ld_type: {ctyp_type, ctyp_loc}}) => {
257-
let astamp = Current.ident_binding_time(ld_id);
257+
let astamp = Ident.binding_time(ld_id);
258258
{Type.Attribute.stamp: astamp, name, typ: Shared.makeFlexible(ctyp_type), typLoc: ctyp_loc}
259259
}))
260260
}
@@ -267,7 +267,7 @@ let forSignatureItem = (~env, ~exported: Module.exported, item) => {
267267
| Tsig_value({val_id, val_loc, val_name: name, val_desc, val_attributes}) => {
268268
let declared = addItem(
269269
~name,
270-
~stamp=Current.ident_binding_time(val_id),
270+
~stamp=Ident.binding_time(val_id),
271271
~extent=val_loc,
272272
~contents={Value.typ: Shared.makeFlexible(val_desc.ctyp_type), recursive: false},
273273
~env,
@@ -282,7 +282,7 @@ let forSignatureItem = (~env, ~exported: Module.exported, item) => {
282282
}
283283
| Tsig_module({md_id, md_attributes, md_loc, md_name: name, md_type: {mty_type}}) => {
284284
let contents = forModuleType(env, mty_type);
285-
let declared = addItem(~contents, ~name, ~extent=md_loc, ~stamp=Current.ident_binding_time(md_id), ~env, md_attributes, exported.modules, env.stamps.modules);
285+
let declared = addItem(~contents, ~name, ~extent=md_loc, ~stamp=Ident.binding_time(md_id), ~env, md_attributes, exported.modules, env.stamps.modules);
286286
[{...declared, contents: Module.Module(declared.contents)}]
287287
}
288288
| Tsig_include({incl_mod, incl_type}) =>
@@ -342,14 +342,14 @@ let rec forItem = (
342342
Value.recursive: false,
343343
typ: Shared.makeFlexible(pat_type),
344344
};
345-
let declared = addItem(~name, ~stamp=Current.ident_binding_time(ident), ~env, ~extent=vb_loc, ~contents, vb_attributes, exported.values, env.stamps.values);
345+
let declared = addItem(~name, ~stamp=Ident.binding_time(ident), ~env, ~extent=vb_loc, ~contents, vb_attributes, exported.values, env.stamps.values);
346346
Some({...declared, contents: Module.Value(declared.contents)})
347347
| _ => None
348348
},
349349
bindings)
350350
| Tstr_module({mb_id, mb_attributes, mb_loc, mb_name: name, mb_expr: {mod_desc}}) => {
351351
let contents = forModule(env, mod_desc, name.txt);
352-
let declared = addItem(~contents, ~name, ~extent=mb_loc, ~stamp=Current.ident_binding_time(mb_id), ~env, mb_attributes, exported.modules, env.stamps.modules);
352+
let declared = addItem(~contents, ~name, ~extent=mb_loc, ~stamp=Ident.binding_time(mb_id), ~env, mb_attributes, exported.modules, env.stamps.modules);
353353
[{...declared, contents: Module.Module(declared.contents)}]
354354
}
355355
| Tstr_include({incl_mod, incl_type}) =>
@@ -367,7 +367,7 @@ let rec forItem = (
367367
topLevel
368368

369369
| Tstr_primitive({val_id, val_name: name, val_loc, val_attributes, val_val: {val_type}}) => {
370-
let declared = addItem(~extent=val_loc, ~contents={Value.recursive: false, typ: Shared.makeFlexible(val_type)}, ~name, ~stamp=Current.ident_binding_time(val_id), ~env, val_attributes, exported.values, env.stamps.values);
370+
let declared = addItem(~extent=val_loc, ~contents={Value.recursive: false, typ: Shared.makeFlexible(val_type)}, ~name, ~stamp=Ident.binding_time(val_id), ~env, val_attributes, exported.values, env.stamps.values);
371371
[{...declared, contents: Module.Value(declared.contents)}]
372372
}
373373
| Tstr_type(decls) =>
@@ -384,7 +384,7 @@ and forModule = (env, mod_desc, moduleName) => switch mod_desc {
384384
}
385385
| Tmod_functor(ident, argName, maybeType, resultExpr) => {
386386
maybeType |?< t => forTreeModuleType(~env, t) |?< kind => {
387-
let stamp = Current.ident_binding_time(ident);
387+
let stamp = Ident.binding_time(ident);
388388
let declared = newDeclared(
389389
~contents=kind,
390390
~name=argName,

process_ocaml/402/ProcessExtra.re

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ module F = (Collector: {
358358

359359
let enter_signature_item = item => switch (item.sig_desc) {
360360
| Tsig_value({val_id, val_loc, val_name: name, val_desc, val_attributes}) => {
361-
let stamp = Current.ident_binding_time(val_id);
361+
let stamp = Ident.binding_time(val_id);
362362
if (!Hashtbl.mem(Collector.file.stamps.values, stamp)) {
363363
let declared = ProcessAttributes.newDeclared(
364364
~name,
@@ -429,12 +429,12 @@ module F = (Collector: {
429429
addForConstructor(pat_type, lident, constructor)
430430
}
431431
| Tpat_alias(_inner, ident, name) => {
432-
let stamp = Current.ident_binding_time(ident);
432+
let stamp = Ident.binding_time(ident);
433433
addForPattern(stamp, name);
434434
}
435435
| Tpat_var(ident, name) => {
436436
/* Log.log("Pattern " ++ name.txt); */
437-
let stamp = Current.ident_binding_time(ident);
437+
let stamp = Ident.binding_time(ident);
438438
addForPattern(stamp, name);
439439
}
440440
| _ => ()

process_ocaml/406/ProcessCmt.re

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ let rec forSignatureTypeItem = (env, exported: SharedTypes.Module.exported, item
107107
let declared = addItem(
108108
~name=Location.mknoloc(Ident.name(ident)),
109109
~extent=loc,
110-
~stamp=Current.ident_binding_time(ident),
110+
~stamp=Ident.binding_time(ident),
111111
~env,
112112
~contents,
113113
val_attributes,
@@ -139,7 +139,7 @@ let rec forSignatureTypeItem = (env, exported: SharedTypes.Module.exported, item
139139
| Type_variant(constructors) => {
140140
Variant(constructors |. Belt.List.map(({cd_loc, cd_id, cd_args, cd_res, cd_attributes}) => {
141141
let name = Ident.name(cd_id);
142-
let stamp = Current.ident_binding_time(cd_id);
142+
let stamp = Ident.binding_time(cd_id);
143143
let contents = {
144144
Type.Constructor.stamp,
145145
name: Location.mknoloc(name),
@@ -173,13 +173,13 @@ let rec forSignatureTypeItem = (env, exported: SharedTypes.Module.exported, item
173173
}
174174
| Type_record(labels, _) => Record(labels |> List.map(
175175
({ld_id, ld_type}) => {
176-
let astamp = Current.ident_binding_time(ld_id);
176+
let astamp = Ident.binding_time(ld_id);
177177
let name = Ident.name(ld_id);
178178
{Type.Attribute.stamp: astamp, name: Location.mknoloc(name), typ: Shared.makeFlexible(ld_type), typLoc: Location.none}
179179
}
180180
))
181181
}
182-
}, ~name=Location.mknoloc(Ident.name(ident)), ~stamp=Current.ident_binding_time(ident), ~env, type_attributes, exported.types, env.stamps.types);
182+
}, ~name=Location.mknoloc(Ident.name(ident)), ~stamp=Ident.binding_time(ident), ~env, type_attributes, exported.types, env.stamps.types);
183183
[{...declared, contents: Module.Type(declared.contents)}]
184184
}
185185
/* | Sig_module({stamp, name}, {md_type: Mty_ident(path) | Mty_alias(path), md_attributes, md_loc}, _) =>
@@ -194,7 +194,7 @@ let rec forSignatureTypeItem = (env, exported: SharedTypes.Module.exported, item
194194
~extent=md_loc,
195195
~contents=forModuleType(env, md_type),
196196
~name=Location.mknoloc(Ident.name(ident)),
197-
~stamp=Current.ident_binding_time(ident),
197+
~stamp=Ident.binding_time(ident),
198198
~env,
199199
md_attributes,
200200
exported.modules,
@@ -231,7 +231,7 @@ let getModuleTypePath = (mod_desc) => switch mod_desc {
231231
};
232232

233233
let forTypeDeclaration = (~env, ~exported: Module.exported, {typ_id, typ_loc, typ_params, typ_name: name, typ_attributes, typ_type, typ_kind, typ_manifest}) => {
234-
let stamp = Current.ident_binding_time(typ_id);
234+
let stamp = Ident.binding_time(typ_id);
235235
let declared = addItem(~extent=typ_loc, ~contents={
236236
Type.params: typ_params |> List.map(((t, _)) => (Shared.makeFlexible(t.ctyp_type), t.ctyp_loc)),
237237
typ: Shared.makeDeclaration(typ_type),
@@ -248,7 +248,7 @@ let forTypeDeclaration = (~env, ~exported: Module.exported, {typ_id, typ_loc, ty
248248
}
249249
| Ttype_open => Open
250250
| Ttype_variant(constructors) => Variant(constructors |> List.map(({cd_id, cd_name: name, cd_args, cd_res}) => {
251-
let stamp = Current.ident_binding_time(cd_id);
251+
let stamp = Ident.binding_time(cd_id);
252252
{
253253
Type.Constructor.stamp,
254254
name,
@@ -262,7 +262,7 @@ let forTypeDeclaration = (~env, ~exported: Module.exported, {typ_id, typ_loc, ty
262262
}}))
263263
| Ttype_record(labels) => Record(labels |> List.map(
264264
({ld_id, ld_name: name, ld_type: {ctyp_type, ctyp_loc}}) => {
265-
let astamp = Current.ident_binding_time(ld_id);
265+
let astamp = Ident.binding_time(ld_id);
266266
{Type.Attribute.stamp: astamp, name, typ: Shared.makeFlexible(ctyp_type), typLoc: ctyp_loc}
267267
}))
268268
}
@@ -275,7 +275,7 @@ let forSignatureItem = (~env, ~exported: Module.exported, item) => {
275275
| Tsig_value({val_id, val_loc, val_name: name, val_desc, val_attributes}) => {
276276
let declared = addItem(
277277
~name,
278-
~stamp=Current.ident_binding_time(val_id),
278+
~stamp=Ident.binding_time(val_id),
279279
~extent=val_loc,
280280
~contents={Value.typ: Shared.makeFlexible(val_desc.ctyp_type), recursive: false},
281281
~env,
@@ -290,7 +290,7 @@ let forSignatureItem = (~env, ~exported: Module.exported, item) => {
290290
}
291291
| Tsig_module({md_id, md_attributes, md_loc, md_name: name, md_type: {mty_type}}) => {
292292
let contents = forModuleType(env, mty_type);
293-
let declared = addItem(~contents, ~name, ~extent=md_loc, ~stamp=Current.ident_binding_time(md_id), ~env, md_attributes, exported.modules, env.stamps.modules);
293+
let declared = addItem(~contents, ~name, ~extent=md_loc, ~stamp=Ident.binding_time(md_id), ~env, md_attributes, exported.modules, env.stamps.modules);
294294
[{...declared, contents: Module.Module(declared.contents)}]
295295
}
296296
| Tsig_include({incl_mod, incl_type}) =>
@@ -350,14 +350,14 @@ let rec forItem = (
350350
Value.recursive: false,
351351
typ: Shared.makeFlexible(pat_type),
352352
};
353-
let declared = addItem(~name, ~stamp=Current.ident_binding_time(ident), ~env, ~extent=vb_loc, ~contents, vb_attributes, exported.values, env.stamps.values);
353+
let declared = addItem(~name, ~stamp=Ident.binding_time(ident), ~env, ~extent=vb_loc, ~contents, vb_attributes, exported.values, env.stamps.values);
354354
Some({...declared, contents: Module.Value(declared.contents)})
355355
| _ => None
356356
},
357357
bindings)
358358
| Tstr_module({mb_id, mb_attributes, mb_loc, mb_name: name, mb_expr: {mod_desc}}) => {
359359
let contents = forModule(env, mod_desc, name.txt);
360-
let declared = addItem(~contents, ~name, ~extent=mb_loc, ~stamp=Current.ident_binding_time(mb_id), ~env, mb_attributes, exported.modules, env.stamps.modules);
360+
let declared = addItem(~contents, ~name, ~extent=mb_loc, ~stamp=Ident.binding_time(mb_id), ~env, mb_attributes, exported.modules, env.stamps.modules);
361361
[{...declared, contents: Module.Module(declared.contents)}]
362362
}
363363
| Tstr_include({incl_mod, incl_type}) =>
@@ -375,7 +375,7 @@ let rec forItem = (
375375
topLevel
376376

377377
| Tstr_primitive({val_id, val_name: name, val_loc, val_attributes, val_val: {val_type}}) => {
378-
let declared = addItem(~extent=val_loc, ~contents={Value.recursive: false, typ: Shared.makeFlexible(val_type)}, ~name, ~stamp=Current.ident_binding_time(val_id), ~env, val_attributes, exported.values, env.stamps.values);
378+
let declared = addItem(~extent=val_loc, ~contents={Value.recursive: false, typ: Shared.makeFlexible(val_type)}, ~name, ~stamp=Ident.binding_time(val_id), ~env, val_attributes, exported.values, env.stamps.values);
379379
[{...declared, contents: Module.Value(declared.contents)}]
380380
}
381381
| Tstr_type(_, decls) =>
@@ -392,7 +392,7 @@ and forModule = (env, mod_desc, moduleName) => switch mod_desc {
392392
}
393393
| Tmod_functor(ident, argName, maybeType, resultExpr) => {
394394
maybeType |?< t => forTreeModuleType(~env, t) |?< kind => {
395-
let stamp = Current.ident_binding_time(ident);
395+
let stamp = Ident.binding_time(ident);
396396
let declared = newDeclared(
397397
~contents=kind,
398398
~name=argName,

process_ocaml/406/ProcessExtra.re

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ module F = (Collector: {
358358

359359
let enter_signature_item = item => switch (item.sig_desc) {
360360
| Tsig_value({val_id, val_loc, val_name: name, val_desc, val_attributes}) => {
361-
let stamp = Current.ident_binding_time(val_id);
361+
let stamp = Ident.binding_time(val_id);
362362
if (!Hashtbl.mem(Collector.file.stamps.values, stamp)) {
363363
let declared = ProcessAttributes.newDeclared(
364364
~name,
@@ -429,12 +429,12 @@ module F = (Collector: {
429429
addForConstructor(pat_type, lident, constructor)
430430
}
431431
| Tpat_alias(_inner, ident, name) => {
432-
let stamp = Current.ident_binding_time(ident);
432+
let stamp = Ident.binding_time(ident);
433433
addForPattern(stamp, name);
434434
}
435435
| Tpat_var(ident, name) => {
436436
/* Log.log("Pattern " ++ name.txt); */
437-
let stamp = Current.ident_binding_time(ident);
437+
let stamp = Ident.binding_time(ident);
438438
addForPattern(stamp, name);
439439
}
440440
| _ => ()

0 commit comments

Comments
 (0)