Literal byte arrays - #1375
Conversation
0bc4d11 to
03a02c4
Compare
|
The first commit is unrelated: documentation of expressions still made use of the legacy syntax for memory accesses. Then we have:
|
|
I’ve doubts about the |
|
Out of curiosity, is there a specific usecase you have in mind? |
|
|
What should happen in these cases? |
|
For now, I think it is fine for the compiler to reject these programs. I’ve just changed the assertion failure in a better error message. |
| | Ok r => | ||
| match op return sem_t (eval_atype (type_of_opN op).2) -> _ with | ||
| | Opack ws _ => fun w => Papp1 (Oword_of_int ws) (Pconst (wunsigned w)) | ||
| | Oarray len => fun _ => Pbool false |
There was a problem hiding this comment.
To be sure I understand, this is dead code and would typically be an assert false if it were possible?
There was a problem hiding this comment.
Yes, this is dead code. I’m not sure there is a more elegant way to write the same code (here, there are two nested pattern-matching twice on the same value).
There was a problem hiding this comment.
Actually, Rocq is able to elaborate a bit. So you could write
Definition s_opN (op:opN) (es:pexprs) : pexpr :=
match op, app_sopn _ (sem_opN_typed op) es with
| Opack ws _, Ok w => Papp1 (Oword_of_int ws) (Pconst (wunsigned w))
| Ocombine_flags _, Ok b => Pbool b
| _, _ => PappN op es
end.
There was a problem hiding this comment.
(and this has no impact on the proof it seems)
There was a problem hiding this comment.
Thanks. I’ll apply your suggestion.
eponier
left a comment
There was a problem hiding this comment.
I made suggestions for the doc. Also I'm surprised that global_in_global_def.jazz now passes. Shouldn't it complain that we're going u8 -> u16 conversion at some point?
Apart from that, this seems good to go.
It looks like |
|
Right. |
Co-authored-by: Jean-Christophe Léchenet <jean-christophe.lechenet@inria.fr>
9ed76e8 to
a15a3e2
Compare
You’re perfectly right. Thanks. I’ve added the missing check in pretyping and now the test case fails again, as expected. |
eponier
left a comment
There was a problem hiding this comment.
This is good, and I don't want to delay it further. I made one suggestion about the definition of s_opN. Just tell me if you want to integrate it. In any case, I'll merge the PR.
Description
This adds literal (byte) arrays to the language of expressions. In source code they can be written using string syntax (e.g.,
"data") or array syntax (e.g.,{ x, y + z }). Both syntax were already accepted for top-level definitions of global variables.Fixes #510
This PR is marked as draft as it needs a bit of polishing (see checklist below).Future work (not for this PR): generalize the type of cells (currently limited to
u8).Checklist
changesif the PR is a user-visible changecompiler/testsif it makes sense, especially if it is a bug fix