Restrict type sections to only inherit from other type sections

This commit is contained in:
Sasha Koshka 2022-10-13 16:33:32 -04:00
parent bfdca9ed16
commit c047a1438a
1 changed files with 10 additions and 0 deletions

View File

@ -129,6 +129,16 @@ func (analyzer analysisOperation) analyzeTypeSection () (
outputSection.what, err = analyzer.analyzeType(inputSection.Type())
if err != nil { return }
// type sections are only allowed to inherit other type sections
_, inheritsFromTypeSection := outputSection.what.actual.(*TypeSection)
if !inheritsFromTypeSection {
err = inputSection.Type().NewError (
"type sections can only inherit from other type " +
"sections.",
infoerr.ErrorKindError)
return
}
if !inputSection.Argument().Nil() {
outputSection.argument,
err = analyzer.analyzeArgument(inputSection.Argument())