boschresearch / blech

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

Singleton function should not be callable in condition #43

Closed schorg closed 3 years ago

schorg commented 3 years ago

Describe the bug Singleton functions are functions that have a side effect on global resources. Calling them in conditions should not be allowed.

To Reproduce

@[CFunction (binding ="c_f", header = "c_f.h")]
extern singleton function f () returns bool

@[EntryPoint]
activity Main ()
    await f() // singleton in condition -> non-determinism
end

Compiles without complains.

Expected behaviour The type checker should detect that the call f() might have a side effect and flag an error.