Friday, May 25, 2007

Safari: SyntaxError - Parse error

I have now worked my way past this particularly opaque Safari error message twice, which is one time too many, so I am putting the explanation for my error case online. Safari seems to have a few cases where it throws up this utterly useless error message. It does include a line number reference, and double-clicking the error line in the log will take you to the offending line, but heaven help you if it is not clear what is wrong at that point.

I found another reference to this problem on the web, but it wasn't the problem I had.

My problem was that I used "abstract" as a variable name. Because I am working on web pages for viewing presentation abstracts, this seemed natural, however I guess "abstract" is a reserved word of some kind in Safari's Javascript implementation. Firefox showed no errors and happily ran code that Safari could not even parse.


crschmidt said...

In general, Safari is a good thing to have around for this, because IE would have broken but *not* given you an error, so you'd have been left in the dark...

(I don't know if this applies to 'abstract', but it definitely applies to 'long', which sucks for geo developers.)

At least Safari gives you an error message. The fact that Firefox's Javascript engine is so accepting as to choose to not fail on this syntax error is hardly Safari's fault.

Jeremy said...

Thank you so much for posting this. When working with Google Maps, I had to debug a syntax error in a custom marker function (that passed latitude and longitude as "lat" and "long" as parameters. Changed "long" to "lng" and it began working.

An interesting note-- this error does NOT occur in Safari 3 (as of this writing.)

I would suspect that all the browsers have long as a reserved keyword. The behavior might be, in these browsers, to place reserved keywords in a different name space to avoid collisions. Just a hunch, but I would argue that it's safer that bailing like Safari 2 does.

Martin said...

thanks for this! I had same problem - safari didn't like a function called goto. gofigure!

mats said...

Same here. Safari 2 was choking on a variable named 'package'. Safari 3 was fine.

rbrenner said...

I encountered this same difficulty with respect to a missing hyphen in an HTML close comment ("-->") wrapping some JavaScript. Safari threw an error, with this ambiguous message. Much staring was required.

Justin said...

I had this issue too. If you look at the code within safari's develop tool the offending variables will be marked in blue as the browser thinks the are reserve terms.

Neer Friedman said...

same goes for the 'class' keyword, as well as all of the following: class enum extends super const export import (defined in ECMAScript Language Specification, section 7.6.1 Reserved Words)

About Me

My Photo
Victoria, British Columbia, Canada


Blog Archive


bc (38) it (30) postgis (23) video (12) enterprise IT (11) icm (11) gis (9) sprint (9) open source (8) osgeo (8) cio (6) enterprise (6) foippa (6) management (6) spatial it (6) foi (5) foss4g (5) mapserver (4) outsourcing (4) politics (4) bcesis (3) boundless (3) opengeo (3) oracle (3) rant (3) COTS (2) architecture (2) deloitte (2) esri (2) idm (2) javascript (2) natural resources (2) ogc (2) open data (2) openstudent (2) postgresql (2) technology (2) vendor (2) web (2) 1.4.0 (1) HR (1) access to information (1) accounting (1) agile (1) aspen (1) benchmark (1) buffer (1) build vs buy (1) business (1) business process (1) c (1) career (1) cartodb (1) cathedral (1) client (1) cloud (1) code (1) common sense (1) consulting (1) contracting (1) core review (1) crm (1) crockofshit (1) cunit (1) custom (1) data warehouse (1) design (1) development (1) digital (1) email (1) environment (1) essentials (1) evil (1) exadata (1) fcuk (1) fgdb (1) fme (1) foocamp (1) foss4g2007 (1) ftp (1) gdal (1) gds (1) geocortex (1) geometry (1) geoserver (1) geotiff (1) google (1) google earth (1) government (1) grass (1) hp (1) iaas (1) icio (1) imagery (1) industry (1) innovation (1) integrated case management (1) introversion (1) iso (1) isss (1) isvalid (1) jpeg (1) jts (1) lawyers (1) mapping (1) mcfd (1) microsoft (1) mysql (1) new it (1) nosql (1) nrs transformation (1) opengis (1) openlayers (1) oss (1) paas (1) pirates (1) policy (1) portal (1) proprietary software (1) qgis (1) rdbms (1) recursion (1) redistribution (1) regression (1) rfc (1) right to information (1) saas (1) salesforce (1) sardonic (1) seibel (1) sermon (1) server (1) siebel (1) snark (1) spatial (1) standards (1) svr (1) taxi (1) tempest (1) texas (1) tired (1) transit (1) twitter (1) uber (1) udig (1) uk (1) uk gds (1) verbal culture (1) victoria (1) waterfall (1) wfs (1) where (1) with recursive (1) wkb (1)