Macros work badly with [trigger | type check] #1726
Catoverflow
started this conversation in
Language design
Replies: 1 comment
-
TriggerIf I use error: triggers cannot contain let/forall/exists/lambda/choose
--> src/v2/controllers/vdeployment_controller/proof/predicate.rs:34:28
|
34 | closure_to_fn_spec(|s: ReconcileLocalState| {
| ____________________________^
35 | | let vds = VDeploymentReconcileState::unmarshal(s).unwrap();
36 | | at_step_internal!(vds, $($tokens)+)
37 | | })
| |_________^
|
::: src/v2/controllers/vdeployment_controller/proof/liveness/terminate.rs:93:47
|
93 | assert forall |n: nat| #![trigger at_step!((AfterScaleDownOldVRS, old_vrs_list_len(n)), Error)] n > 0 implies spec.entails(temp_at_step!(controller_id, vd, (AfterScaleDownOldVRS, old_vrs_list_len(n)), Error)
| ------------------------------------------------------------ in this macro invocation
|
= note: this error originates in the macro `at_step` (in Nightly builds, run with -Z macro-backtrace for more info)Verus is unhappy with |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to use macro to express a predicate that accepts a flexible number of arguments. It worked but broke the types and triggers.
I have encountered a few type check problems:
Closure and SpecFn
I have to call
closure_to_fn_specto make Verus aware that it can be a spec, the minimum reproduction code isclosure_to_fn_specis not documented. I found this using-Zunpretty=expandedfollowing Bryan's suggestions (thank you Bryan!). I think this conversion should also be automated.Integer Type Conversion
This problem happens for macro and enum, I have to choose between E0308 and E0605:
If I use
at_step!((AfterScaleDownOldVRS, |vds| vds.old_vrs_list.len() == 0)I gotIf I use
at_step!((AfterScaleDownOldVRS, |vds| vds.old_vrs_list.len() == 0 as nat)I gotenum's version can be found here:
The solution is hacky:
== in macro
You may noticed the strange way of using
==:$vds.reconcile_step.eq_step($step). If I use==I gotThe actual type that trigger this error was not shown, so I hacked Verus to print the types on each side of
==.VDeploymentReconcileStepViewis a ghost type and can be compared safely inspec, so my workaround isIs it because of the type information is not fully available during macro substitution?
Beta Was this translation helpful? Give feedback.
All reactions