Conversation
|
Oh, cool! Do I see it correctly that, for two instances |
Felalolf
left a comment
There was a problem hiding this comment.
I only have one minor comment, the rest seems fine.
...ain/scala/viper/gobra/frontend/info/implementation/typing/ghost/separation/GhostTyping.scala
Outdated
Show resolved
Hide resolved
Co-authored-by: Felix Wolf <60103963+Felalolf@users.noreply.github.com>
|
I'm not the biggest fan of special casing the encoding for ghost structs as this seems rather confusing to users. Instead, I've implemented a type checker warning for this case in the separate PR #826 |
Hmm, in that case, I would rather throw a type error rather than a warning, given that The way I see it, ghost structs are useful as alternatives to ADT with a single constructor. However, for ADTs we do have a meaningful EDIT: To add to this, I had two instances where I was bitten by the unexpected semantics for |
|
I agree with your statement that ghost types use == like ===. My fear is related to the different semantics between a ghost struct and a struct with just ghost fields, which feels like very similar things to me, but maybe I'm wrong here and we should indeed have == mean different things for ghost structs and structs with just ghost fields |
|
@jcp19 I've now implemented equality ( |
…claration with an underlying ghost type
src/test/resources/regressions/features/defunc/pred-construct-fail1.gobra
Show resolved
Hide resolved
|
So far, I am just clarifying a bigger point that I noticed while I was looking at the tests. After that is clarified, I will take a look at the rest |
jcp19
left a comment
There was a problem hiding this comment.
I think I found an unsoundness in ghost embeddings, please check out my comment
src/test/resources/regressions/features/ghost_type/ghost-type-decl-simple01.gobra
Show resolved
Hide resolved
src/test/resources/regressions/features/ghost_type/ghost-struct-type-fail02.gobra
Outdated
Show resolved
Hide resolved
src/test/resources/regressions/features/ghost_type/ghost-struct-comparison-fail02.gobra
Show resolved
Hide resolved
src/main/scala/viper/gobra/translator/encodings/structs/StructEncoding.scala
Outdated
Show resolved
Hide resolved
src/main/scala/viper/gobra/frontend/info/implementation/typing/TypeTyping.scala
Show resolved
Hide resolved
...in/scala/viper/gobra/frontend/info/implementation/typing/ghost/separation/GhostWellDef.scala
Outdated
Show resolved
Hide resolved
…reflect how we parse and type check an actual type definition with a ghost type
Co-authored-by: João Pereira <joaopereira.19@gmail.com>
jcp19
left a comment
There was a problem hiding this comment.
LGTM! Before merging, please let me try these changes out in SCION to see if there are any blocking issues. I will let you know soon
|
Interestingly, trying to verify the |
|
No blocking issues found in SCION, I have a PR ready to land as soon as this is merged (viperproject/VerifiedSCION#398), so feel free to do so when the tests pass |
How come an exception is not a blocking issue? ^^ |
Good point 🤣 By blocking issues, I was looking out for idioms that are used in practice that are no longer allowed or easily replaceable, whereas this is an exception that occurs when type errors should be thrown. I agree this should be fixed before merging |
547bb60 to
2b76293
Compare
I just checked: merging this PR with #855 and running the following command in the VerifiedSCION repo (viperproject/VerifiedSCION@a6638e1) no longer results in an exception but (as expected) type errors |
|
CI is currently failing as #855 must be first merged |
|
@ArquintL from my side, we can go ahead and merge this |
This PR adds support for Ghost Types, i.e., the ability to mark a named type or type alias as ghost such that this type is erased. This feature came up in the context of structs that are declared for verification-only purposes and, thus, contain only ghost fields. To avoid any confusion, we restrict ghostness of a type declaration to match the ghostness of its RHS. In addition, this PR fixes an issue where type declarations were not correctly considered being ghost despite declaring a name for a ghost type. As a side-effect, ADT can no longer be method receiver as they are ghost.
In addition, this PR makes
PPermissionTypeandPPredTypeghost types, which did not use to be the case.