[Bug] [kompile] - Error with seqstrict/context alias in non-main module

Open
#2,640 2 comments 0 reactions 1 assignee View on GitHub

@PetarMax is already working on this.

Since Oct 20, 2022.

Assessment

This issue has not been assessed yet.

Description

bug

K Version

$ kompile --version
K version:    v5.3.68-0-g8d3077659-dirty
Build date:   Mon Jun 06 15:03:24 BST 2022

Description

kompile reports an error when a module split into syntax and semantics, the former features a rule label used with seqstrict, the latter uses the same label with context alias, and a different module is designated as the main module.

Origin: K Basic Tutorial, Chapter 14, error reported in module LESSON-14-C when compiling with main module LESSON-14-D.

Input Files

File: kompile-bug.k

module BUGGY-MODULE-SYNTAX
  imports BOOL-SYNTAX

  syntax Exp ::= Bool
               > left: Exp "&&" Exp [seqstrict(exp; 1, 2)]
endmodule

module BUGGY-MODULE
  imports BUGGY-MODULE-SYNTAX
  imports BOOL

  context alias [exp]: <k> HERE ...</k>
  
  syntax Bool ::= isKResult(K) [function, symbol]
  
endmodule

module EMPTY-MODULE
endmodule

File: kompile-no-bug.k

module BUGGY-MODULE
  imports BOOL

  syntax Exp ::= Bool
               > left: Exp "&&" Exp [seqstrict(exp; 1, 2)]

  context alias [exp]: <k> HERE ...</k>
  
  syntax Bool ::= isKResult(K) [function, symbol]
  
endmodule

module EMPTY-MODULE
endmodule

Reproduction Steps

Run kompile with EMPTY-MODULE as the main module:

$ kompile kompile-bug.k --main-module EMPTY-MODULE
[Error] Compiler: Found rule label "exp" in strictness attribute which did not
refer to any sentence.
	Source(/Users/petarmax/Projects/RV/Tutorial/01 - Basic/14/kompile-bug.k)
	Location(5,24,5,59)
	5 |	               > left: Exp "&&" Exp [seqstrict(exp; 1, 2)]
	  .	                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[Warning] Compiler: Could not find main syntax module with name
EMPTY-MODULE-SYNTAX in definition.  Use --syntax-module to specify one. Using
EMPTY-MODULE as default.

Note 1: Running kompile with BUGGY-MODULE as main module succeeds:

$ kompile kompile-bug.k --main-module BUGGY-MODULE
$

Note 2: When the syntax is not separate from the semantics (kompile-no-bug.k), the error disappears:

$ kompile kompile-no-bug.k --main-module EMPTY-MODULE
[Warning] Compiler: Could not find main syntax module with name
EMPTY-MODULE-SYNTAX in definition.  Use --syntax-module to specify one. Using
EMPTY-MODULE as default.

Expected Behavior

Successful compilation, no errors reported.

Dominant language
Python
Stars
591
Forks
163
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

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.

More from runtimeverification/k

All issues in runtimeverification/k

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.