angular / angular.js

AngularJS - HTML enhanced for web apps!
https://angularjs.org
MIT License
58.87k stars 27.52k forks source link

SyntaxError: Unexpected number with 1.3.0 #9646

Closed clakech closed 9 years ago

clakech commented 9 years ago

Hi,

We migrate from 1.2.X to 1.3.0 and face a strange error on loading the app:

SyntaxError: Unexpected number at Function (native) at getterFn (http://localhost:9000/angular/angular.js:12302:26) at Lexer.readIdent (http://localhost:9000/angular/angular.js:11690:31) at Lexer.lex (http://localhost:9000/angular/angular.js:11531:14) at Parser.parse (http://localhost:9000/angular/angular.js:11773:30) at $parse (http://localhost:9000/angular/angular.js:12411:39) at $interpolate (http://localhost:9000/angular/angular.js:9922:25) at addTextInterpolateDirective (http://localhost:9000/angular/angular.js:7898:27) at collectDirectives (http://localhost:9000/angular/angular.js:7088:11) at compileNodes (http://localhost:9000/angular/angular.js:6909:22) angular.js:11358(anonymous function) angular.js:11358(anonymous function) angular.js:8445processQueue angular.js:12922(anonymous function) angular.js:12930Scope.$eval angular.js:14123Scope.$digest angular.js:13939$delegate.proto.$digest VM822:844Scope.$apply angular.js:14227$delegate.proto.$apply VM822:855done angular.js:9493completeRequest angular.js:9678requestLoaded angular.js:9621 2SyntaxError: Unexpected number

Any idea of what can lead to this kind of error ?

pkozlowski-opensource commented 9 years ago

@clakech I guess you would get answer in no time provided that you isolate the issue and send a minimal reproduce scenario using http://plnkr.co/

clakech commented 9 years ago

of course, I am working on it.

But I hoped this error was obvious to other people migrating from 1.2 to 1.3 ;)

My app is a > 20000 loc so isolate the problem may take a while.

I am back soon, with a solution of plnkr!

Ce message et toutes les pièces jointes sont établis à l'attention exclusive de leurs destinataires et sont confidentiels. Si vous recevez ce message par erreur, merci de le détruire et d'en avertir immédiatement l'expéditeur. L'internet ne permettant pas d'assurer l'intégrité de ce message, le contenu de ce message ne représente en aucun cas un engagement de la part de GROUPE ADEO.

caitp commented 9 years ago

well, an expression within an interpolated string is clearly throwing --- maybe it's throwing when creating the function, or maybe it's throwing when evaluating the function. It's not totally clear, but it would definitely be good to see a list of strings like {{ ... }} in your app

lgalfaso commented 9 years ago

shooting darts in the dark: I would expect that you have some expression that tries to access an object and when it expects an identifier it finds a number. E.g foo.42, this can be in {{...}} or some parameter to a directive

clakech commented 9 years ago

thx

yes I see many strings like {{ emptyListMessageKey | wkI18n }} in the browser.

I am investigating in my filter wkI18n now.

May I have some foo.42 somewhere

Ce message et toutes les pièces jointes sont établis à l'attention exclusive de leurs destinataires et sont confidentiels. Si vous recevez ce message par erreur, merci de le détruire et d'en avertir immédiatement l'expéditeur. L'internet ne permettant pas d'assurer l'intégrité de ce message, le contenu de ce message ne représente en aucun cas un engagement de la part de GROUPE ADEO.

pkozlowski-opensource commented 9 years ago

@lgalfaso I think I would throw the same dart (with my eyes closed :-)). Sth like foo.number, ex.: foo.5

clakech commented 9 years ago

I found this in a template:

{{ content.webtopList.Image.0 }}

...

This was working before. But not now ;-)

Ce message et toutes les pièces jointes sont établis à l'attention exclusive de leurs destinataires et sont confidentiels. Si vous recevez ce message par erreur, merci de le détruire et d'en avertir immédiatement l'expéditeur. L'internet ne permettant pas d'assurer l'intégrité de ce message, le contenu de ce message ne représente en aucun cas un engagement de la part de GROUPE ADEO.

clakech commented 9 years ago

Obviously replacing {{ content.webtopList.Image.0 }} to {{ content.webtopList.Image[0] }} avoid this error

nkatevarapu commented 9 years ago

Hi, We migrate from 1.2.23 to 1.3.0 and faced issue with date format what i am expecting is this -10/17/2014 the resulting thing is this - Fri Oct 17 2014 10:25:08 GMT+0530 (IST) is it because of migration or because of any bootstrap changes.But it is fine with angular1.2.23 version after migrated to 1.3.0 only i faced this issue. Any idea please...?

wbeange commented 9 years ago

I had a similar error message and I was able to isolate the issue to a $http.post call.

My server (ruby on rails) call for this particular end point was only returning a hash as return data (text format). This was allowed in v1.2 but was breaking for v1.3.

I changed my server to return a json object and that solved my issue.

Hopefully this saves somebody a headache.

devyreham commented 9 years ago

ok it seems Angular 1.3 is stricter about JSON format, overall. It doesn't parse properties starting with a number. Unfortunately I have a chemical drug called 5HT3ReceptorAntagonist. So it needs to be replaced by ['5HT3ReceptorAntagonist']. This wasn't valid Javascript anyway

caitp commented 9 years ago

yeah, it was for performance reasons, i'm not sure how big of a win it was but I think it's documented in the changelog