Closed mterber closed 4 years ago
param
declarations are not fully supported, right now. This is a combination of errors in the analysis phases.
For the time being you should declare size as read-only
let size: uint8 = len + 1
I've tried to reproduce your issue with a minimal example using only the involved data elements:
@[EntryPoint]
activity SendCommand (len: uint8)
param size: uint8 = len + 1
await false
end
However the compiler correctly detects error: The static paramter size was initialised by SendCommand.len + 1 which assumes a value at runtime. Instead it must be initialised using only constants or other static paramters. --> .\sendCommand.blc:4:11 [typing]
Please check if your build of blechc is up to date.
I can confirm that this issue was caused by an outdated version of the Blech compiler. I actually compiled and updated the compiler executable correctly but my helper script, which executes the Blech compiler for every *.blc file in my project, still pointed to an older version of the Blech compiler. The same is true for my VS code plugins which where also based on the older compiler version.
So from my point of view this issue is fixed.
The following activity code compiles in Blech without any errors:
The resulting C code, however, is rejected by the C compiler:
Blech compiler: c30608eb866acaa026e9e7199ca9a93f8262f3d6