Emacs-D-Mode-Maintainers / Emacs-D-Mode

An Emacs mode for D code.
GNU General Public License v3.0
84 stars 22 forks source link

Highlighting doesn't work properly for `const` without explicit type #30

Closed atilaneves closed 8 years ago

atilaneves commented 10 years ago

auto foo = getFoo() and immutable foo = getFoo() highlight foo as a new variable introduction (as it should) but const foo = getFoo() highlights foo as a type (expecting something like const Foo foo).

russel commented 10 years ago

I can confirm this to be the case, I hadn't noticed before. However, I think the problem is that auto and immutable are wrong rather than const being wrong: const is listed as a modifier so it's behaviour is as it should be in some sense, auto and immutable are hacked in a special hack rather than being handled by the standard mechanisms.

It would seem then that we should remove const from it's modifier status and add it to the specially hacked along with auto and immutable. I guess the questions are whether auto, immutable and const are identical as symbols and so should be treated the same, and will anything break by making such a change.

I suggest we might benefit from wider debate on this one?

atilaneves commented 10 years ago

Well, there's also the complication that this is valid:

const auto foo = 4;
immutable auto bar = 4;

I don't mind the debate, but for me when const and immutable show up by themselves I'd expect them to be font-locked as types. In any case, the variable being highlighted properly is the most important issue to me.