3

I'm currently trying to compile a python project (5files @ total 1200 lines of code) with shedskin.

I tried shedskin Version 0.9.3 and 0.9.2 both result in the same errors. This is the first error I encounter:

mmain.cpp: In function ‘__shedskin__::list<__shedskin__::list<int>*>* __mmain__::list_comp_3(__shedskin__::__ss_int)’:
mmain.cpp:133: error: no matching function for call to ‘__shedskin__::list<__shedskin__::list<int>*>::append(__shedskin__::list<double>*)’

Moreover, I after running shedskin (i.e. before typing "make") I receive many warnings - all related to dynamic types:

*WARNING* mmain.py: expression has dynamic (sub)type: {float, int, list}

However, shedskin seems to work flawlessly with the provided examples since I can compile and execute them without any errors.

Do you have an idea where to look for the error or what the error is related to?

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
user1829358
  • 1,041
  • 2
  • 9
  • 19

2 Answers2

1
mmain.cpp:133: error: no matching function for call to ‘__shedskin__::list<__shedskin__::list<int>*>::append(__shedskin__::list<double>*)’

This error means that you've got a Python object that shedskin has inferred as a list of lists of ints, but now you're trying to append something that it's inferred as a list of floats. You can get that by, for example, doing this:

a = [[1], [2]]
b = 1.0
a.append([b])

However, from the line above it, the function name is list_comp_3. Unless you've actually named a function list_comp_3 (which you haven't), this is a list comprehension. So, you may be doing something like this:

a = [1, 2, 3.0]
b = [[i] for i in a]

You may be wondering why it let you get away with a but failed on b. Well, first of all, it probably didn't really let you get away with it, if you've got dozens of warnings you haven't dealt with. But second, as the documentation says:

Integers and floats can often be mixed, but it is better to avoid this where possible, as it may confuse Shed Skin:

a = [1.0]

a = 1 # wrong - use a float here, too

As for the warnings, they can mean anything from "you got away with it this time, but don't expect to always do so" to "an error is coming up related to this" to "this will compile, but to something less efficient than the original Python code rather than more" to "this will compile, but to something incorrect".

More generally, it sounds like your program just can't be statically typed by shedskin's inference engine. Without actually seeing your code, it's impossible to tell you what you're doing wrong, but if you re-read the Typing Restrictions and Python Subset Restrictions sections of the docs, that should give you ideas of what kinds of things are and aren't appropriate.

abarnert
  • 354,177
  • 51
  • 601
  • 671
  • Thanks. This has pointed me into the right direction. I preallocated a list with integers and lateron filled it with instaces of some class A. I'm currently trying to resolve this issue. Have a look [here](https://groups.google.com/forum/#!topic/shedskin-discuss/Byau6fWFgRo) if you want to have further information about how to resolve this issue. – user1829358 Jan 08 '13 at 10:52
1

to avoid confusion, please note that both code snippets provided by 'abartert' compile and run fine when compiled separately (shedskin 0.9.3). my guess is also that the problem should disappear after resolving the dynamic typing warnings. if not, I'd be very interested in seeing the program you are trying to compile, or at least enough of it to reproduce the problem.

update: btw, as of 0.9.1 or so, shedskin should be smarter about int and float mixing. if it encounters something that would lead to broken or inefficient c++ code (because of necessary run-time conversion of sorts), it should now usually complain with an 'incompatible types' warning. so perhaps it's time to update this part of the documentation slightly for 0.9.3.

srepmub
  • 104
  • 3