diff --git a/analyzer/type.go b/analyzer/type.go index 57bdf7a..e3345a0 100644 --- a/analyzer/type.go +++ b/analyzer/type.go @@ -197,8 +197,21 @@ func (analyzer analysisOperation) analyzeType ( bitten, err = analyzer.fetchSectionFromIdentifier(inputType.Name()) - outputType.actual = actual.(*TypeSection) - // TODO: produce an error if this doesnt work + if actual == nil { + err = inputType.NewError ( + "this type does not exist", + infoerr.ErrorKindError) + return + } + + var worked bool + outputType.actual, worked = actual.(*TypeSection) + if !worked { + err = inputType.NewError ( + "this must refer to a type or an interface", + infoerr.ErrorKindError) + return + } if bitten.Length() > 0 { err = bitten.NewError( diff --git a/tests/analyzer/typeSection/main.arf b/tests/analyzer/typeSection/main.arf index bd58795..b61de1d 100644 --- a/tests/analyzer/typeSection/main.arf +++ b/tests/analyzer/typeSection/main.arf @@ -1,4 +1,5 @@ :arf +require './something' --- type ro aBasicInt:Int 5 @@ -8,3 +9,5 @@ type ro bOnBasicInt:aBasicInt type ro cBasicObject:Obj ro that:Int ro this:Int + +type ro dInheritedFromOther:something.Thing diff --git a/tests/analyzer/typeSection/something/main.arf b/tests/analyzer/typeSection/something/main.arf new file mode 100644 index 0000000..7440373 --- /dev/null +++ b/tests/analyzer/typeSection/something/main.arf @@ -0,0 +1,3 @@ +:arf +--- +type ro Thing:Int