18

It appears that recently the Apex compiler has changed - for the better it seems.

Here are some typical messages:

Example 1:

String s = "hey";

Results:

Error:Error:line (6)Unrecognized symbol '"', which is not a valid Apex identifier.
Error:Error:line (6)Unrecognized symbol '"', which is not a valid Apex identifier.
Error:Error:line (1)". Message was "no viable alternative at character '"'".
Error:Error:line (1)". Message was "no viable alternative at character '"'".
Error:Error:line (6)Variable does not exist: hey

Example 2:

Integer x = 0
String y = 'something';

Results:

Error:(7, 5) unexpected syntax: 'missing SEMICOLON at 'String''

Example 3:

if (true == true))

Results:

Error:(6, 22) unexpected token: ')'

Example 4:

String[] stuff = new String[]{'whats up'

Results:

Error:(9, 5) unexpected syntax: 'mismatched input 'VestingData' expecting RCURLY'

The messages appear more specific and clear - however, I can't find any org which still has the old compiler to compare with.

Does anyone have any insight into this pleasant phenomenon?

Specifically:

  • Are there any important differences between the old compiler and the new?
  • Does the new compiler provide any new functionality that I could take advantage of?
  • How has the apparent speed increase been achieved?
  • Is there a concrete roadmap of future updates that we should know about?
15
  • 1
    Presume you've seen this youtube.com/watch?v=Yc5FrviQqO8? Lots about caching but talks about new compiler rollout too.
    – Keith C
    Commented Aug 28, 2017 at 23:42
  • 3
    I've also noticed it won't let you put an OR statement into a SOQL WHERE clause that also contains an AND statement without wrapping it in parenthesis, which is a nice little catch for a common error. Commented Aug 29, 2017 at 0:22
  • 2
    Could it be tied to the Release version? Most orgs are currently on 17 Patch 19.2 with a few exceptions. AP9, CS116, CS115 are still on 18.0 (AWS hosted?). Commented Aug 29, 2017 at 1:35
  • 2
    In addition to more specific errors, I've noticed that the new compiler doesn't give up and die at the first sign of an error like it used to. Where possible, it will report multiple compilation errors. This can reduce the number of code-compile-fix cycles when writing new code. Commented Aug 29, 2017 at 4:03
  • 2
    I won't believe it until my switch statement compiles :)
    – smukov
    Commented Aug 29, 2017 at 6:14

1 Answer 1

14

I can confirm that the new Apex compiler appears to be in place.

I took the first example from Winter '18 Apex Compiler Changes and tested in out in my dev org. It no longer compiles with Summer'17 Patch 19.2. It isn't immediately clear if the Apex compiler is tied to the release version.

enter image description here

Winter 18 came early! At least as far as the compiler is concerned.

The help article linked above contains the "important differences between the old compiler and the new".

I suspect you will see some new Apex functionality going forward once the compiler is settled in place. These would usually be heralded by the release notes. Things like Deployments Now Recompile of All Apex Code and the @isTest(isParallel=true) spring to mind as being related to the new compiler. This is just a guess on my part.

3
  • Awesome!!! I just read that article - thanks for finding it - very good information to know. And yes, there were probably other things that would have been good to have in this drop, but perhaps there'll be more coming down the line. Commented Aug 29, 2017 at 1:56
  • 2
    I can say that the deployment recompilation is not related to the new compiler. I've been using the pilot of that feature for a while internally. Commented Aug 29, 2017 at 2:05
  • @ca_peterson Fair enough. I'm not even sure about my isParallel example either. Only reasoning was it was bumped from the last release. Like it couldn't go out without the compiler change. I'm just guessing though. Commented Aug 29, 2017 at 2:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .