; Writing through a file opened for reading is rejected by the verifier. ; expect: reject E1001 ; phase: 2 ; spec: docs/spec/06-resources-and-errors.md module test.wrong_file_mode air 0 lang 0.1 features [arrays, capabilities, effects, ownership, resources] fn @f(%c: cap, %p: slice) -> void effects [fs.read] entry: intrinsic fs.open_read(%c, %p), ok -> @opened, err -> @fail opened(%f: file): %m = borrow.mut %f intrinsic fs.write_all(%m, %p), ok -> @w, err -> @wf w: borrow.end %m intrinsic fs.close(%f), ok -> @x, err -> @xf x: ret xf(%e3: io_error): ret wf(%e2: io_error): borrow.end %m intrinsic fs.close(%f), ok -> @x, err -> @xf fail(%e: io_error): ret