Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/typecheck.ml
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,18 @@ let rec synth (ctx : context) (expr : expr) : ty result =
| _ ->
let* () = unify_or_err operand_ty ty_int in
Ok ty_int)
| OpDeref ->
(* Lenient deref: `*e` peels one borrow layer when `e` is a
reference type, but is the identity on a value type. Params
declared with a `ref`/`mut` mode are lowered to their bare
value type (the borrow checker tracks the actual borrow), so
stdlib code that reads them via `*self` / `*other` must still
type-check. Real `TRef`/`TMut`/`TOwn` still peel to the inner
type. *)
let* operand_ty = synth ctx operand in
(match repr operand_ty with
| TRef t | TMut t | TOwn t -> Ok t
| t -> Ok t)
| _ ->
let (operand_ty, result_ty) = type_of_unop op in
let* () = check ctx operand operand_ty in
Expand Down
Loading