function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jim CripeJim Cripe 

Bug: Apex parser doesn't allow string constants to end with backslash

The Apex parser has a bug that won't allow a backslash to end string constants.

Try "System.debug('\\');" to see the problem. 

The compiler thinks the string is unterminated and gives compile error "line breaks not allowed in string literals".

I have a workaround:

String DirectoryPath = '\\\\test\\file\\path';

String BackSlash = '\\this'; //Try to remove 'this' from the string and try to run to see the bug
BackSlash = BackSlash.replace('this', ''); //Hack to be able to build backslash terminated character string

DirectoryPath = DirectoryPath + ( DirectoryPath.EndsWith(BackSlash) ? '' : BackSlash );

System.debug(DirectoryPath);

Jim CripeJim Cripe
When I got no action on this discussion board posting on 6/13, I submitted this as a case on 6/18, case 01932606. 

I got this email on 6/24 regarding the case:
--------------------

Thank you for contacting Salesforce.com Technical Support.

I would like to inform you that the support you are requesting requires higher level of expertise.

Please contact our developer team at http://developer.salesforce.com and submit a query.

If you have any questions or concerns do not hesitate to contact us at 1-800-667-6389 for further information.

Kind regards,

<blanked support person's name>
salesforce.com
-------------------

When I logged in to developer, I found the case was closed, and when I called to find out what to do, I was told to submit to the issue to the discussion boards.  

I informed the technician that I had already done that and sent him the URL to the original posting.

He is going to try to get someone to look into  the issue.

It took eleven days to get this far?!  : (





Message Edited by Jim Cripe on 06-24-2008 12:40 PM
Jim CripeJim Cripe
I received notice that the bug has been reproduced and escalated to the SalesForce support engineers.
gjsgjs

I apologize for the run around we gave you and thank you for not giving up on us. A bug has been created: #191851.

Jim CripeJim Cripe
Winter '09, as of today, still has this bug in the Apex compiler.

I just tested in our Sandbox1 that has been updated to Winter '09.

Doing this, (execute anonymous):

System.debug('\\');

Will get this error:

Compile error at line 1 column -1
line breaks not allowed in string literals

Is there any estimated time for this bug to be fixed?

Jim CripeJim Cripe
Just tested and the bug is fixed!

I didn't get any word back from SF on the fix though.

Doing this (execute Anonymous):

System.debug('\\');

Now gets this:

Anonymous execution was successful.

20081117230815.478:AnonymousBlock: line 1, column 1: Anonymous
20081117230815.478:AnonymousBlock: line 1, column 1: System.debug(String)
20081117230815.478:AnonymousBlock: line 1, column 1: \



tggagnetggagne

But can a string literal span multiple source lines?

 

string xmlString = '<xml>\

<child /> \

<\xml>';

 

Unfortunately, not.