Fix error handling of invalid subscope variable assignments

This commit is contained in:
Louis Gesbert 2022-10-26 11:09:15 +02:00
parent 96b623c724
commit 47a1258648

View File

@ -671,10 +671,16 @@ let get_def_key
| [y; x] ->
let (subscope_uid, subscope_real_uid) : SubScopeName.t * ScopeName.t =
match
Desugared.Ast.IdentMap.find (Marked.unmark y) scope_ctxt.var_idmap
Desugared.Ast.IdentMap.find_opt (Marked.unmark y) scope_ctxt.var_idmap
with
| SubScope (v, u) -> v, u
| _ -> invalid_arg "subscope_real_uid"
| Some (SubScope (v, u)) -> v, u
| Some _ ->
Errors.raise_spanned_error pos
"Invalid access to input variable, '%s' is not a subscope"
(Marked.unmark y)
| None ->
Errors.raise_spanned_error pos "No definition found for subscope '%s'"
(Marked.unmark y)
in
let x_uid = get_var_uid subscope_real_uid ctxt x in
Desugared.Ast.ScopeDef.SubScopeVar (subscope_uid, x_uid, pos)