Skip to content

Commit

Permalink
Update free variable error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ShinWonho committed Jul 23, 2024
1 parent 898fef7 commit 958a35c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions spectec/src/backend-interpreter/ds.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@ let string_of_env env =
let lookup_env key env =
try Env.find key env
with Not_found ->
Printf.eprintf "The key '%s' is not in the map: %s.\n%!"
key (string_of_env env);
raise Not_found
let freeVar s = Exception.FreeVar s in
env
|> string_of_env
|> Printf.sprintf "The key '%s' is not in the map: %s.\n%!" key
|> freeVar
|> raise


(* Info *)
Expand Down
1 change: 1 addition & 0 deletions spectec/src/backend-interpreter/exception.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exception Timeout
exception MissingReturnValue of string
exception InvalidArg of string
exception InvalidFunc of string
exception FreeVar of string

(* For AL-level debugging *)
exception Error of Util.Source.region * string * string
1 change: 1 addition & 0 deletions spectec/src/backend-interpreter/interpreter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ let try_with_error fname at stringifier f step =
| Construct.InvalidConversion msg
| Exception.InvalidArg msg
| Exception.InvalidFunc msg
| Exception.FreeVar msg
| Failure msg -> error at (prefix ^ msg) (stringifier step)


Expand Down

0 comments on commit 958a35c

Please sign in to comment.