runtimeverification / runtimeverification/llvm-backend

[Bug] [kompile] - kompile emits a "Non exhaustive match detected" warning for a seemingly sufficiently complete function definition

Open
#495 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
43
Forks
22
PR merge metrics
No merged PRs in 30d

Description

K Version

$ kompile --version
K version:    5.2.97
Build date:   Sun Mar 06 11:36:17 CST 2022

Description

kompile emits a "Non exhaustive match detected" warning seemingly unnecessarily in some cases (see the minimal example below). The function for which it gives the warning is declared functional and is sufficiently completely specified as far as I can tell.

Note: when uncommenting the owise line in the example below, the warning is not shown. But it shouldn't be needed, I think.

Input Files

The owise.k file below:

module OWISE-SYNTAX
  syntax T ::= "uint"
  syntax TList ::= List{T, ""} [klabel(list)]
endmodule

module OWISE
  imports OWISE-SYNTAX

  syntax MaybeT     ::= T | "NoT"
  syntax MaybeTList ::= List{MaybeT, ""} [klabel(list)]
  syntax MaybeTList ::= TList

  syntax MaybeTList ::= foo(MaybeTList) [function, functional]
  // ---------------------------------------------------------
  rule foo(.MaybeTList)            => .MaybeTList
  rule foo(_:MaybeT TL:MaybeTList) => uint foo(TL)
  //rule foo(TL) => TL [owise] // to suppress a totality checker warning
endmodule

Reproduction Steps

kompile --syntax-module OWISE-SYNTAX owise.k

Expected Behavior

No "Non exhaustive match detected" warning is emitted.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal example in owise.k and run kompile --syntax-module OWISE-SYNTAX owise.k to reproduce the totality-checker warning. Trace how the foo rules are analyzed, then confirm that the sufficiently complete functional definition no longer emits the warning without the owise rule.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.