开云体育

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Unable to use interface method argument in `when` guard


 

It is intentional.? The logical order of events for a method is that the RDY is available first, then the arguments are provided (and an EN signal, if it's an action), and then the return value is output (if it has one).? So a method's RDY can't depend on its arguments.? Though BSC could certainly be improved to give a more direct error message, than just the generic one about the variable not being in scope.

J


On Mon, Mar 24, 2025 at 1:21?AM Yehowshua Immanuel via <programmed4jesus=gmail.com@groups.io> wrote:

Un-commenting the commented-out lines in the snippet below...
?
?
?
retireTag :: UIntLog2N(numTags) -> Action
retireTag tag =
do
let nextStackPtrUint =
case stackPtr of
Nothing -> 0
Just n -> n + 1
(select inUseVec tag) := False
(select freeStackVec nextStackPtrUint) := tag
stackPtr := Just nextStackPtrUint
-- when
-- tag < (reifiedNumTags - 1),
-- readReg (select inUseVec tag)
?
causes compilation to fail with:
?
?
```bash
$TOPMODULE=mkSim make b_compile b_link b_sim
mkdir ?-p build_b_sim
Compiling for Bluesim ...
bsc -u -sim -simdir build_b_sim -bdir build_b_sim -info-dir build_b_sim -keep-fires -aggressive-conditions -no-warn-action-shadowing -check-assert -cpp -show-schedule +RTS -K128M -RTS ?-show-range-conflict ? ? ?-p bs/:bsv/:+ -g mkSim ?bs/Top.bs?
checking package dependencies
<snipped>
5 warnings generated.
compiling bs//TagEngine.bs
Warning: "bs//TagEngine.bs", line 43, column 8: (P0223)
? Definition of `counter' is not used.
Error: "bs//TagEngine.bs", line 70, column 20: (T0004)
? Unbound variable `tag'
make: *** [Makefile:103: b_compile] Error 1
```
?
Is this intentional? Are you not allowed to use interface method arguments in when guards?

Join b-lang-discuss@groups.io to automatically receive all group messages.