From c047a1438aa8a7c9757a2be5ef025f37140dc90f Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 13 Oct 2022 16:33:32 -0400 Subject: [PATCH] Restrict type sections to only inherit from other type sections --- analyzer/type-section.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/analyzer/type-section.go b/analyzer/type-section.go index 43cb904..f18354c 100644 --- a/analyzer/type-section.go +++ b/analyzer/type-section.go @@ -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())