Skip to content
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

Recursive fixpoint: Inductive argument is not detected as a switch pattern var. #54

Open
necto opened this issue Oct 30, 2016 · 2 comments

Comments

@necto
Copy link
Contributor

necto commented Oct 30, 2016

I am building a large fixpoint, that contains nested switch statements. For some reason the code below fails with the following

"Inductive argument of recursive call must be switch clause pattern variable."

Although, the two_switch_fp(bt, nil) does use the switch clause pattern variable bt.

/*@
  fixpoint list<kt> two_switch_fp<kt>(list<kt> current_bucket, list<int> start) {
    switch(start) {
      case nil:
        return switch(current_bucket) {
          case nil:
            return nil;
          case cons(bh, bt):
            return two_switch_fp(bt, nil);
        };
      case cons(h,t):
        return nil;
    }
  }
  @*/

How can I make it more explicit?

@necto necto changed the title Double-switch fixpoint: Inductive argument is not detected as a pattern var. Recursive fixpoint: Inductive argument is not detected as a switch pattern var. Oct 30, 2016
@btj
Copy link
Member

btj commented Oct 30, 2016

The error message is not precise: the inductive argument of a recursive call must be a switch clause pattern variable of the outermost switch statement (or a component thereof).

So the fix in this case is simply to swap the nesting order of the two switch statements.

@necto
Copy link
Contributor Author

necto commented Oct 30, 2016

That works. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants