boschresearch / blech

Blech is a language for developing reactive, real-time critical embedded software.
Apache License 2.0
72 stars 5 forks source link

Handle abstract types in type checking #46

Closed schorg closed 3 years ago

schorg commented 3 years ago

Describe the todo When compiling signatures, abstract types are not handled.

module exposes init

struct S 
    var x: bool
end

function init() returns S 
    return {x = true}
end

gets signature

signature

@[ComplexType]
type S

function init() returns S

type S is currently not handled by the typechecker. Attributes @[ComplexType] and @[SimpleType] are currently not handled by the attribute checker.

Link to a branch Typechecking and attribute checking codegeneration for feature/modules Testcase

Task list To mark completed todos, use [x]

FriedrichGretz commented 3 years ago

The type checker now does check annotations for opaque types and checks initialisation of opaque typed variables.

However, export inference is not checked. Can we ensure that, e.g.

schorg commented 3 years ago

Yes we can.

The import compilation for export inference only runs the phases before the type checker and then generates the signature.

I added a valid test case to the export inference tests. Just run the test: exportinference/valid/useabstractsimple.blc and inspect the generated signature in: exportinference/imports/abstractsimple.blh