k-legacy icon indicating copy to clipboard operation
k-legacy copied to clipboard

Custom list in configuration, strange bug

Open omarzd opened this issue 9 years ago • 2 comments

I think I found another bug in K4.0. See the following code:

module TEST
  imports TEST-SYNTAX
  configuration   
    <T>
      <k> $PGM:Pgm </k>  
      <p> .Ids </p>
    </T>

  rule <k> Ps:Ids => .Ids </k>
       <p> Ps </p>
endmodule

module TEST-SYNTAX
  syntax Pgm ::= Ids
  syntax Ids  ::= List{Id, ","}
  syntax Ints ::= List{Int,","}
endmodule

kompile will return the following error:

[Error] Compiler: Had 1 parsing errors.
[Error] Critical: Unexpected sort Ids for term Ps. Expected Ints.
        Source(test.k)
        Location(10,12,10,14)

Any of the following will fix the problem:

  • Removing <p> .Ids </p>
  • Removing syntax Ints ::= List{Int,","}
  • Changing the Ints delimiter to something else like ;

omarzd avatar May 08 '16 18:05 omarzd

Following @cos's suggestion, I changed the line in the configuration which has the custom list .Ids to <p> .Ids:Ids </p>, to explicitly define the sort; and that solved the problem. As I understood, the bug was that in this case both .Ints and .Ids will have the same list ending which is why the parser confused them. However another bug turned up when I tried the double colon operator. <p> .Ids::Ids </p> produces the same error.

omarzd avatar May 11 '16 21:05 omarzd

this is still a bug, so let's leave it open

cos avatar May 11 '16 23:05 cos