Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
devops committed Dec 15, 2023
2 parents 0b4353c + 322f223 commit 5864ffd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Runtime Verification, Inc. All Rights Reserved.
module CHECKPARAMETRICSORT
imports MINT
imports INT

syntax MInt{6}
syntax {S} Foo{S}
endmodule
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Error] Compiler: User-defined parametric sorts are currently unsupported: Foo{S}
Source(checkParametricSort.k)
Location(7,1,7,18)
7 | syntax {S} Foo{S}
. ^~~~~~~~~~~~~~~~~
16 changes: 14 additions & 2 deletions kore/src/main/scala/org/kframework/definition/outer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,21 @@ case class Module(
set.head
}

// check that non-terminals have a defined sort
private def throwIfUserParametricSort(sort: Sort, loc: HasLocation): Unit =
if (sort.head.params != 0 && sort.name != Sorts.MInt.name)
throw KEMException.compilerError(
"User-defined parametric sorts are currently " +
"unsupported: " + sort,
loc
)

// Check that user-defined sorts are non-parametric and that
// each non-terminal has a defined sort
def checkSorts(): Unit = localSentences.foreach {
case p @ Production(_, params, _, items, _) =>
case s @ SyntaxSort(_, sort, _) => throwIfUserParametricSort(sort, s)
case s @ SortSynonym(newSort, _, _) => throwIfUserParametricSort(newSort, s)
case p @ Production(_, params, sort, items, _) =>
throwIfUserParametricSort(sort, p)
val res = items.collect {
case nt: NonTerminal
if !p.isSortVariable(nt.sort) && !definedSorts.contains(nt.sort.head) && !sortSynonymMap
Expand Down

0 comments on commit 5864ffd

Please sign in to comment.