FStar icon indicating copy to clipboard operation
FStar copied to clipboard

Failing verification conditions are shown as type-class resolution errors

Open gebner opened this issue 8 months ago • 1 comments

module TypeErr
open Pulse
#lang-pulse

let fin (n: nat) = i:nat { i < n }

fn foo #k (r: ref (fin k)) (v: erased (fin (-10)))
  requires pts_to r v
  (*       ^^^^^^
  Could not solve typeclass constraint
    `has_pts_to (ref (fin k)) (erased (fin (- 10)))`
  *)
  ensures pts_to r v
{
  ()
}

This should ideally give an error on -10 instead.

gebner avatar Mar 04 '25 19:03 gebner

This error also appears in pure F*. Apparently type class resolution is (a) run before sending the VCs to Z3 and (b) eagerly discharges VCs itself.

let bar #k (r: ref (fin k)) (v: erased (fin (-10))) =
  pts_to r v
(*^^^^^^
Could not solve typeclass constraint
    `has_pts_to (ref (fin k)) (erased (fin (- 10)))`
*)

gebner avatar Mar 04 '25 22:03 gebner