Review Request 119178: Set every declaration as always direct

Denis Steckelmacher steckdenis at yahoo.fr
Tue Jul 8 13:19:15 UTC 2014


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/119178/
-----------------------------------------------------------

Review request for KDevelop.


Repository: kdev-qmljs


Description
-------

This patch calls "setAlwaysForceDirect" on every declaration created by the QMLJS plugin. I don't know what are all the implications, but it solves a nasty bug:

var dont_use_me;
var array = {};
array.dont_use_me = "fail";

In this snippet, without this patch, "array.dont_use_me" is considered to be an use of "var dont_use_me". I've verified that UseBuilder does not create an use for "var dont_use_me" on line 3. It still creates an use for "array.dont_use_me" that is automatically declared on line 3, though.

I think that line 3 is still considered to be an use of line 1 because the two incrimined declarations (the variable and the object member) have the same name. Moreover, "array" has an internal context that has no name, so the scope of the two declarations is the same. Using only their name, there is no way to differentiate them, hence the unwanted use. By forcing every declaration to be direct, this problem disappears.

I would like some advice here because the fact that a declaration is direct or not seems to have deep implications in KDevelop. Is it correct to have every declaration direct? Why is this not the case by default?


Diffs
-----

  duchain/declarationbuilder.h 1ab77a1 
  duchain/declarationbuilder.cpp 2ec2f49 
  tests/files/arrays.js e9a8efa 

Diff: https://git.reviewboard.kde.org/r/119178/diff/


Testing
-------

The whole testsuite still passes and a new unit test is added (it looks like the example given above). The unit test fails without this patch and passes when this patch is applied. The testsuite is not slowed down nor sped up by this patch.


Thanks,

Denis Steckelmacher

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20140708/6ed06eb0/attachment.html>


More information about the KDevelop-devel mailing list