Replies: 2 comments
-
|
According to ChatGPT :
|
Beta Was this translation helpful? Give feedback.
-
|
This snippet does raise exceptions when executed, but it typechecks just fine (as intended). To build it and run it, you can add a call to the function in the tail of the file let _ = dynamicChecking ()(This makes sure it's actually called, otherwise this file just defines a bunch of functions.) And then build it and run it like so (the warnings are benign) $ fstar.exe --codegen OCaml X.fst
* Warning 272 at X.fst(63,0-63,26):
- Top-level let-bindings must be total; this term may have effects
Extracted module X
Verified module: X
All verification conditions discharged successfully
$ fstar.exe --ocamlopt X.ml
File "X.ml", line 23, characters 6-8:
23 | let v1 = read tmp in let v2 = read readme in write tmp "hello!"
^^
Warning 26 [unused-var]: unused variable v1.
File "X.ml", line 23, characters 27-29:
23 | let v1 = read tmp in let v2 = read readme in write tmp "hello!"
^^
Warning 26 [unused-var]: unused variable v2.
File "X.ml", line 30, characters 6-8:
30 | let v1 = checkedRead tmp in
^^
Warning 26 [unused-var]: unused variable v1.
File "X.ml", line 31, characters 6-8:
31 | let v2 = checkedRead readme in
^^
Warning 26 [unused-var]: unused variable v2.
File "X.ml", line 32, characters 6-8:
32 | let v3 = checkedRead passwd in
^^
Warning 26 [unused-var]: unused variable v3.
$ ./a.out
Dummy read of file demo/tempfile
Dummy read of file demo/README
Fatal error: exception X.InvalidRead |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
why aren't any exceptions raised in the below code?
Many thanks.
Beta Was this translation helpful? Give feedback.
All reactions