[Differential] [Request, 70 lines] D3770: Create declaration for lambda expressions

flherne (Francis Herne) noreply at phabricator.kde.org
Tue Dec 20 23:51:30 UTC 2016


flherne created this revision.
flherne added a reviewer: brauch.
flherne set the repository for this revision to R53 KDevelop: Python Support.
Restricted Application added a subscriber: kdevelop-devel.

REVISION SUMMARY
  This is an alternative to D3555 <https://phabricator.kde.org/D3555>.
  
  Lambda expression improvements.
  
  Lambda expressions were given the type of their return expression, e.g. `lambda x: 12` has type "int".
  
  That caused calling them to get no or an incorrect return type:
  `a = (lamba x: 12)("arg")`  # a should be int, but is mixed.
  BUG: 306212
  
  They should have a function type instead.
  
  `*args` or `**kwargs` arguments to a lambda were shown as undefined in the return expression:
  `lambda *args, **kwargs: args[1] + kwargs["foo"]`
  
  The types of arguments were never known, even with default arguments.
  
  Create function declarations for lambdas; this is slightly hacky but allows the use of `visitArguments()` and `addArgumentTypeHints()` without modification.
  
  Lambdas do now show up in the outline view, which is not ideal.

TEST PLAN
  Fixes one test. Adds five more, none of which passed before.
  No test regressions.
  
  I'll run duchainify over the python3.5 source before pushing.

REPOSITORY
  R53 KDevelop: Python Support

REVISION DETAIL
  https://phabricator.kde.org/D3770

AFFECTED FILES
  duchain/declarationbuilder.cpp
  duchain/expressionvisitor.cpp
  duchain/expressionvisitor.h
  duchain/tests/pyduchaintest.cpp
  parser/ast.cpp
  parser/ast.h
  parser/astbuilder.cpp

EMAIL PREFERENCES
  https://phabricator.kde.org/settings/panel/emailpreferences/

To: flherne, brauch
Cc: kdevelop-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20161220/1cd17a99/attachment-0001.html>


More information about the KDevelop-devel mailing list