Closed haltman-at closed 4 years ago
value
is pretty common as a variable name. What do you think about highlighting any identifier followed by a colon?
Yeah, the value
problem bothered me too. On the other hand, I'm not sure "identifier followed by a colon" works well either. There are two obstacles I notice that bother me. One is that there could be whitespace inbetween, but seems minor and handleable; we can account for that. The bigger problem to my mind is that this overlaps with Solidity's named-argument syntax (yeah, it's not well-documented, quite annoyingly), which also uses identifiers followed by colons.
Maybe we could distnguish the two? Like, maybe with more work we could distinguish named arguments from these sorts of parameters? Like, maybe a (
followed by a {
(possibly with whitespace inbetween) would put us in a "named arguments" mode, but outside that mode we'd have the identifier-followed-by-colon rule? Or maybe just specifically gas
, value
, salt
when followed by colon? This all might require some mode-wrangling...
I thought about named arguments, and there's also struct construction. But I don't see a problem with highlighting all of those too.
On the other hand we could also just leave all of gas
, value
, salt
without any highlighting at all. I don't see a problem with that.
Whoo, finally getting back to this. I think there just isn't any totally satisfactory solution to this unfortunately. Current thinking: Maybe just highlight gas
, value
, and salt
when followed immediately by a colon? That should probably be good enough most of the time...
Let's go ahead with that and see how it works out. We can always roll back if we don't like the result.
OK, pushed that!
Whoops, one last change: I made it so that the special parameters can be used in a few other places too (as technically they could appear in a modifier invocation or base constructor invocation).
Anyway I'll merge and release this in a bit I guess!
This PR contains updates for Solidity 0.6.2. Specifically:
The literals
true
andfalse
are now allowed in assembly mode.I added
gas
,value
, andsalt
as builtins due to the new function-call syntax? I'm not sure builtin is really the right place for these, but I couldn't figure out what was better... I mean they're not keywords, surely? (Like, pretty sure you can still use them as variable names, e.g.) IDK, if anyone has a better idea, please suggest it. (I mean ideally we'd only highlight them in context, but that seems really hard!)(Also, in my previous PR, I accidentally used tabs instead of spaces at one point... oops! Fixed here.)