Skip to content

Chained conjunction forces spec mode #1149

@jonhnet

Description

@jonhnet

Run this with verus:

use builtin_macros::verus;

verus!{
    exec fn foo(a: usize, b: usize, c: usize) -> usize {
        if a <= b <= c { 1 } else { 2 }
    }
}

You'll get error: condition must have mode exec, which is quite confusing.

A workaround is to replace the condition with a <= b && b <= c, so evidently operator chaining causes the expression to suddenly become a spec expression.

Is there any reason we shouldn't allow chained expressions in exec text and desugar them to a collection of conjuncts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions