3

I am trying to use google closure compiler on my javascript files. It works fine except for the following piece of code:

function goto(form) { var index=form.select.selectedIndex
if (form.select.options[index].value != "0") {
location=form.select.options[index].value;}}

The compiler returns:

JSC_PARSE_ERROR: Parse error. missing ( before function parameters. at line 1 character 9 function goto(form) { var index=form.select.selectedIndex

There is a caret (^) pointing to the g in "goto" when it is output on the screen.

I am using just the basic UI version here to test:

http://closure-compiler.appspot.com/home

Any idea what is wrong with the javacript? It seems to work just fine but I am not a javascript person so I have no clue how to fix it.

1
  • 1
    well it is missing a semicolon after selectedIndex, doubt that is the issue. Commented Jun 14, 2013 at 13:57

1 Answer 1

4

I am not sure why @Sirko deleted his answer. So I will add it.

You need to change the name of the function goto to something else. Something like gotoUrl, gotoPage, etc.

It was a reserved word in ECMAScript 3, but removed in ECMAScript 5. I am guessing the closure compiler uses that older list still.

Sign up to request clarification or add additional context in comments.

2 Comments

that fixed it, thanks! I was having flashbacks to BASIC programming when I saw that goto in the first place
Javascript has a weird and wonderful list of reserved words, most of which don't appear in the language itself, consequently they are unguessable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.