[K-Bug] `#let`, `#as`, and `#fun` break type safety

Open
#3,838 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start by running kompile on the three reproductions: test-let.k, test-as.k, and test-fun.k. Trace the front-end type checking for #let, #as, and #fun, using the shown outputs as the expected behavior. Done means each invalid use reports a type error instead of compiling with only a warning or no diagnostic.

Written by the indexing model from the issue text.

Description

What component is the issue in?

Front-End

Which command
  • kompile
  • kast
  • krun
  • kprove
  • kprovex
  • ksearch
What K Version?

v6.0.137

Operating System

Linux

K Definitions (If Possible)

test-let.k

module TEST-LET
syntax Void
syntax Foo ::= foo()
syntax Top ::= start()
             | Evil(Void)

rule start() => #let X = foo() #in Evil(X)
endmodule

test-as.k

module TEST-AS
syntax Void
syntax Top ::= start()
             | Evil(Void)

rule start() #as X => Evil(X)
endmodule

test-fun.k

module TEST-FUN                                                                                                                                                                                             
syntax Void
syntax Foo ::= foo()
syntax Top ::= start()
             | Evil(Void)                                                                                                                                                                                   

rule start() => #fun(X => Evil(X))(foo())
endmodule
Steps to Reproduce
  • kompile test-let.k --main-module TEST-LET --syntax-module TEST-LET
    • Output: [Warning] Compiler: Non exhaustive match detected: `#lambda__`(_)
  • kompile test-as.k --main-module TEST-AS --syntax-module TEST-AS
    • Output:
  • kompile test-fun.k --main-module TEST-FUN --syntax-module TEST-FUN
    • Output: [Warning] Compiler: Non exhaustive match detected: `#lambda__`(_)
Expected Results

We should report a type error in all cases.

test-let.k

[Error] Inner Parser: Unexpected sort Foo for variable X. Expected: Void
	Source(test-let.k)
	Location(7,41,7,42)
	7 |	rule start() => #let X = foo() #in Evil(X)
	  .	                                        ^
[Error] Compiler: Had 1 parsing errors.

test-as.k

[Error] Inner Parser: Unexpected sort Top for variable X. Expected: Void
	Source(test-as.k)
	Location(6,28,6,29)
	6 |	rule start() #as X => Evil(X)
	  .	                           ^
[Error] Compiler: Had 1 parsing errors.

test-fun.k

[Error] Inner Parser: Unexpected sort Foo for term parsed as production syntax 
Foo ::= "foo" "(" ")" [klabel(foo)]. Expected: Void
	Source(test-let.k)
	Location(7,36,7,41)
	7 |	rule start() => #fun(X => Evil(X))(foo())
	  .	                                   ^~~~~
[Error] Compiler: Had 1 parsing errors.
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.