Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error for with block misuse #56

Closed
jemcmahan13 opened this issue Mar 11, 2015 · 1 comment
Closed

Better error for with block misuse #56

jemcmahan13 opened this issue Mar 11, 2015 · 1 comment
Labels
enhancement Proposed feature requests and improvements

Comments

@jemcmahan13
Copy link
Contributor

With blocks should have the form

with ConditionalUpdate() as condition:
    with condition(...):
    ...
    with condition(...):
    ...
    etc.

Since the keywords and structure are intuitive, a common error may be to forget that each with statement takes a ConditionalUpdate object as argument (and not just a condition). E.g.,

with ConditionalUpdate() as condition:
    with (...):
    ...
    with (...):
    ...
    etc.

Right now this throws AttributeError: __exit__, which is not helpful if you don't know what you did wrong. If possible, a better error message would be useful.

Here's a complete example that throws the error message:

import sys
sys.path.append("..")
import pyrtl

a = pyrtl.WireVector(1)
b = pyrtl.WireVector(1)
c = pyrtl.WireVector(1)

with pyrtl.ConditionalUpdate() as condition:
    with condition(a & b):
        c |= 1
    with (a | b):
        c |= 0
@jemcmahan13 jemcmahan13 added the enhancement Proposed feature requests and improvements label Mar 11, 2015
@timsherwood
Copy link
Contributor

fixed and test added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Proposed feature requests and improvements
Projects
None yet
Development

No branches or pull requests

2 participants