dan-fritchman / Hdl21

Hardware Description Library
BSD 3-Clause "New" or "Revised" License
69 stars 16 forks source link

"Failure to assign" error feedback #184

Open dan-fritchman opened 1 year ago

dan-fritchman commented 1 year ago

Example:

@h.module 
class M:
  i = h.Input()
  o = h.Output()
  s = h.Signal()

There is a similar-looking, but not-working, alternative one might write like so:

@h.module 
class M:
  h.Input(name="i")
  h.Output(name="o")
  h.Signal(name="s")

That "works", in the sense that Python will compile and execute it. But it is highly unlikely to be what the author intended. In the latter case the hdl21.Module M is empty.

Note I do not think the latter should "work". It would be nice to produce some kinda error or feedback though.

But - either "working" or just producing the error would seem to require some tracking of execution context, which I don't love.
Maybe something better will come up.