-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Propagate Cryptol error strings #1344
base: master
Are you sure you want to change the base?
Conversation
This patch adds two new SAWCore primitives: * `appendString : String -> String -> String`, which appends the underlying `Text` values in a `String`, and * `bytesToString : (n : Nat) -> Vec n (Vec 8 Bool) -> String`, which converts a Cryptol string (a sequence of 8-bit ASCII characters) to a SAWCore `String`. Moreover, this reimplements `ecError` in terms of `appendString`/`bytesToString` such that invoking the Cryptol `error` function from SAW will preserve the string passed to `error`. Previously, if you invoked the following in SAW: ``` sawscript> prove abc {{ error "Descriptive error message" : Bit }} ``` You would get: ``` Run-time error: encountered call to the Cryptol 'error' function ``` Now, you get: ``` Run-time error: encountered call to the Cryptol 'error' function: Descriptive error message ``` Fixes #1326.
@@ -903,6 +903,7 @@ primitive expByNat : (a:sort 0) -> a -> (a -> a -> a) -> a -> Nat -> a; | |||
|
|||
primitive equalString : String -> String -> Bool; | |||
|
|||
primitive appendString : String -> String -> String; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ptival: I believe saw-core-coq
has some special treatment for the appendString
function, so I'm not sure if adding it as a primitive here will cause problems.
@@ -343,6 +345,7 @@ asFirstOrderTypeTValue v = | |||
VSort{} -> Nothing | |||
VRecursorType{} -> Nothing | |||
VTyTerm{} -> Nothing | |||
VStringType -> Nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this case. Does it make sense to add a FOTString
constructor? I'm unclear what the consequences of that would be.
@@ -371,6 +374,7 @@ suffixTValue tv = | |||
VSort {} -> Nothing | |||
VRecursorType{} -> Nothing | |||
VTyTerm{} -> Nothing | |||
VStringType -> Nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, I'm not sure about this use of Nothing
. All of the other Nothing
cases in this function also have corresponding Nothing
cases in asFirstOrderTypeTValue
, so I did the same for VStringType
for consistency.
This patch adds two new SAWCore primitives:
appendString : String -> String -> String
, which appends the underlyingText
values in aString
, andbytesToString : (n : Nat) -> Vec n (Vec 8 Bool) -> String
, which converts a Cryptol string (a sequence of 8-bit ASCII characters) to a SAWCoreString
.Moreover, this reimplements
ecError
in terms ofappendString
/bytesToString
such that invoking the Cryptolerror
function from SAW will preserve the string passed toerror
. Previously, if you invoked the following in SAW:You would get:
Now, you get:
Fixes #1326.