Review Request 117535: If a function contains several return statements of different types, build an UnsureType

Denis Steckelmacher steckdenis at
Sun Apr 13 13:38:17 UTC 2014

This is an automatically generated e-mail. To reply, visit:

(Updated April 13, 2014, 1:38 p.m.)

Review request for KDevelop.


Add a const qualifier to the second argument of mergeTypes, and ignore "mixed" types (unsure(mixed, int) becomes int)

Repository: kdev-qmljs


This patch introduces the mergeTypes() function, based on the same function in kdev-python. Its behavior differs from the Python one in several aspects, though:

* Mixed types absorb other types (the function never returns "unsure(mixed, int)", but simply "mixed"). I'm not sure that it is the right thing to do, but I think that the "mixed" type is generally used to represent an unknown type. The user therefore gains no information by knowing that a function returns "anything, and this anything can sometimes be an int".
* The function makes more assumptions than the Python one. For instance, I know that the second type passed to it is never NULL, and that the function will be used to add a return type to a function or to add a type of a variable.

This function is used to merge the type of all the return statements of a function. This way, the user can know when a function may return values of different types. A future patch will also use this function to deduce the type of variables using assignments to them. 

Diffs (updated)

  duchain/declarationbuilder.cpp fe131ce 
  duchain/helper.h 23a6d0e 
  duchain/helper.cpp 3ffdd56 
  tests/files/helloworld.js 1ce3815 



4 tests have been added. They test the basic features of mergeTypes and some corner cases (how voids should be handled, different return statements having the same type and how mixed should take precedence over other types).


Denis Steckelmacher

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the KDevelop-devel mailing list