kframework / k-legacy

The K tools (deprecated, see README)

Home Page:http://kframework.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parser: no kompile error when using undefined terms in RHS

denis-bogdanas opened this issue · comments

The following definition compiles with no errors:

module ISSUE
  configuration <T> <k> .K </k> </T>
  syntax K  ::= "foo"
  rule foo => bar(.K)
endmodule

Although "bar" is not defined. If you try to run a program that activates the rule, it will throw NoSuchElementException: key not found: bar

This makes semantics definitions prone to typos.

Context: latest K version compiled on 26 Dec 2017.

RHS doesn't matter:

module TEST
  configuration <T> <k> .K </k> </T>
  rule foo(.K) => bar(.K)
endmodule

If I remember correctly, K doesn't look to see if klabels are defined to ease the connection of external parsers.

Sorry for late reply. Thread got lost in some mail folders.

But this is not klabel. External parsers are supposed to use 'Foo(,,)-like notation for KLabels. Anything else should have syntax defined. Or I'm missing something?

So, this is not a well-formed K definition, because the bar klabel is not declared. K 4 changed the syntax of KLabels though, which is why bar now parses as a KLabel.

If you're frustrated by this, I would suggest upgrading to K 5, as we have fixed this issue. A fix for K 4 is very unlikely at this time.

Good to know, thanks!