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

guarded: expected Tuple(Dyn,Dyn) got [<...>,<...>] #15

Open
bennn opened this issue Apr 1, 2016 · 1 comment
Open

guarded: expected Tuple(Dyn,Dyn) got [<...>,<...>] #15

bennn opened this issue Apr 1, 2016 · 1 comment

Comments

@bennn
Copy link

bennn commented Apr 1, 2016

The guarded semantics doesn't allow certain values as Dyn (inside a list).

from retic import List

class A:
  def f(a:A, b:A)->List(A):
    return [a, b]

class B:

    vals = [A(), A()]

    def g(self: B):
        [a1, a2] = (self.vals[0]).f(self.vals[1])

b = B()
b.g()

Traceback

Traceback (most recent call last):
  File "/usr/local/bin/retic", line 5, in <module>
    retic.main()
  File "/home/ben/code/gradual/reticulated/retic/retic.py", line 149, in main
    reticulate(program, prog_args=args.args.split(), flag_sets=args)
  File "/home/ben/code/gradual/reticulated/retic/retic.py", line 98, in reticulate
    utils.handle_runtime_error(exit=True)
  File "/home/ben/code/gradual/reticulated/retic/retic.py", line 96, in reticulate
    _exec(code, __main__.__dict__)
  File "/home/ben/code/gradual/reticulated/retic/exec3/__init__.py", line 2, in _exec
    exec (obj, globs, locs)
  File "bug-expected-tuple.py", line 15, in <module>
    b.g()
  File "/home/ben/code/gradual/reticulated/retic/rproxy.py", line 326, in __call__
    return self.__call__(*args, **kwds)
  File "/home/ben/code/gradual/reticulated/retic/guarded.py", line 208, in wrapper
    else: ret = val(*cargs, **ckwds)
  File "bug-expected-tuple.py", line 12, in g
    [a1, a2] = (self.vals[0]).f(self.vals[1])
  File "/home/ben/code/gradual/reticulated/retic/guarded.py", line 60, in retic_cast
    return retic_cast(val, rtypes.Record({}), trg.structure(), msg, line)
  File "/home/ben/code/gradual/reticulated/retic/guarded.py", line 75, in retic_cast
    retic_assert(hasattr(val, m), val,msg, exc=ObjectTypeAttributeCastError)
  File "/home/ben/code/gradual/reticulated/retic/guarded.py", line 35, in retic_assert
    raise exc(msg % val)
retic.guarded.ObjectTypeAttributeCastError: 
bug-expected-tuple.py:12:8: Right hand side of assignment was expected to be of type Tuple(Dyn,Dyn), but value [<__main__.A object at 0x7fa2b3baa128>, <__main__.A object at 0x7fa2b4323940>] provided instead. (code SINGLE_ASSIGN_ERROR)
@mvitousek
Copy link
Owner

Thanks. This actually looks like a bug in how multiple assignment works; it casts the RHS to a tuple type to make sure it has the correct length but there's a bug in how I do list => tuple casts that leads to this error.
(FYI, Reticulated's implementations of guarded and monotonic are somewhat on the back burner right now compared to transient, so I might not fix these as quickly as I otherwise would. But I'll get to them as soon as possible and I appreciate the reports!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants