Closed GoogleCodeExporter closed 8 years ago
thanks for reporting! this should work without any problem.. but unfortunately,
it
looks like shedskin forgets to add a cast here, so the C++ compiler doesn't
like it.
I will see if I can fix this in SVN. this is an ugly workaround in any case:
def emptydict():
return {}
return {1:1}
d2[2] = emptydict()
Original comment by mark.duf...@gmail.com
on 14 Jan 2010 at 8:42
Original comment by mark.duf...@gmail.com
on 14 Jan 2010 at 8:43
to anyone who would like to help, it would be useful to find similar cases that
fail,
also for other types than dicts.
Original comment by mark.duf...@gmail.com
on 14 Jan 2010 at 8:44
btw, note that the problem is not from using dicts in dicts (still a static
type:
dict(int -> dict(int, int))), but using an empty dict in a way such that
shedskin
forgets to add a cast.. ^^
Original comment by mark.duf...@gmail.com
on 14 Jan 2010 at 8:48
Your comment gave me something to think about, so I tried with lists... and I
found
another set of code that fails:
definiteinnerlist=[1]
outerlist=[]
emptyinnerlist=[]
outerlist.append(definiteinnerlist)
outerlist.append(emptyinnerlist)
The compiler seems to not to find the right cast for a collection, if the only
indication of that collection's type is that it is added to another collection
alongside other members with more definite types.
Original comment by wackywen...@gmail.com
on 14 Jan 2010 at 1:01
Another bypassing solution:
d={1:1}
del d[1]
or fancier, but one line:
d={} and {1:1}
The empty dict (or list) is False, so the 'and' is short-circuited and the
empty-list
is returned, and d is set to the empty list.
Original comment by wackywen...@gmail.com
on 14 Jan 2010 at 1:18
thanks! I will add both tests to the test set, and try to fix the underlying
problem
one of these days. I have to rest a bit first after releasing 0.3.. :-)
Original comment by mark.duf...@gmail.com
on 14 Jan 2010 at 1:35
Original comment by mark.duf...@gmail.com
on 19 Jan 2010 at 8:04
alright, these code fragments now work in SVN. fortunately, the problem was
easier to
solve than I expected. I will close the issue after generalizing the solution a
bit.
thanks again for reporting!
Original comment by mark.duf...@gmail.com
on 17 Mar 2010 at 12:11
I consider this fixed for now. there are a few wacky cases left, but we'll deal
with
them when they turn up.
Original comment by mark.duf...@gmail.com
on 21 Mar 2010 at 9:45
Original issue reported on code.google.com by
wackywen...@gmail.com
on 13 Jan 2010 at 9:11Attachments: