From d78f004848cc21875e79c8649ae1a9a37d59783d Mon Sep 17 00:00:00 2001 From: vbot Date: Wed, 17 Jul 2024 15:06:38 +0200 Subject: [PATCH] Scopelang: fix scope definition incorrect position --- compiler/scopelang/from_desugared.ml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler/scopelang/from_desugared.ml b/compiler/scopelang/from_desugared.ml index 630d6f1e..0211dd8c 100644 --- a/compiler/scopelang/from_desugared.ml +++ b/compiler/scopelang/from_desugared.ml @@ -598,12 +598,15 @@ let translate_rule (exc_graphs : Desugared.Dependency.ExceptionsDependencies.t D.ScopeDef.Map.t) = function | Desugared.Dependency.Vertex.Var (var, state) -> ( - let pos = Mark.get (ScopeVar.get_info var) in - (* TODO: this may point to the place where the variable was declared instead - of the binding in the definition being explored. Needs double-checking - and maybe adding more position information *) let scope_def = - D.ScopeDef.Map.find ((var, pos), D.ScopeDef.Var state) scope.scope_defs + D.ScopeDef.Map.find + ((var, Pos.no_pos), D.ScopeDef.Var state) + scope.scope_defs + in + let pos = + match RuleName.Map.choose_opt scope_def.scope_def_rules with + | None -> Mark.get (ScopeVar.get_info var) + | Some (r, _) -> Mark.get (RuleName.get_info r) in match ScopeVar.Map.find_opt var scope.scope_sub_scopes with | None -> (