Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-5217 in a recent build.
  1. #1
    Ext JS Premium Member
    Join Date
    Jul 2008
    Location
    New Zealand
    Posts
    91
    Vote Rating
    3
    Greendrake is on a distinguished road

      0  

    Default [4.1-20120123] Unable to use 'class' model fields

    [4.1-20120123] Unable to use 'class' model fields


    It's pretty understandable that the word class is a reserved word in JavaScript and so it's not a good idea to use that word as a name of variable. As for keys/identifiers (such as model/record field names), it has never been a problem. Until ExtJS 4.1.
    So, the following code
    Code:
    Ext.define('Foo', {
        extend: 'Ext.data.Model',
        fields: ['class']
    });
    generates a "class is a reserved identifier" error on Firefox 9.0.1):

    class-ext4.1.png

    For some reason, field identifiers get evaluated to variables.
    So, the question is: do I have to go through my code and replace all "class" fields with "cls", or is this behaviour unintentional and will be fixed?

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,000
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    This was an unintentional regression, it will be fixed in B3.

    To fix it, in Reader.js:

    Code:
    // current
    fieldVarName[i] = Ext.String.createVarName(field.name);
    
    // fix
    fieldVarName[i] = '_' + Ext.String.createVarName(field.name);
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    St Louis,MO
    Posts
    267
    Vote Rating
    18
    James Goddard will become famous soon enough James Goddard will become famous soon enough

      0  

    Default


    Just want to link back to http://www.sencha.com/forum/showthre...031#post722031.

    It's a bit different. In this case the field name is a reserved word in javascript, in the other case the field name matches a local parameter.

    As you said in the other thread, the same fix will likely take care of both but a linkback is a good idea so we make sure .

    James

  4. #4
    Sencha Premium Member harrydeluxe's Avatar
    Join Date
    Jul 2007
    Location
    N├╝rnberg, Germany
    Posts
    78
    Vote Rating
    29
    harrydeluxe has a spectacular aura about harrydeluxe has a spectacular aura about

      0  

    Default


    The same with "default".
    DELACAP | Github
    "don't code today what you can't debug tomorrow"

  5. #5
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,000
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Just for the sake of completeness, there are 3 types that will fail at the moment:

    1) Reserved words
    2) Names that conflict with the local vars in the function
    3) Names that start with numbers

    A fix that addresses these cases has been pushed up to the main repo and is awaiting a merge.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  6. #6
    Sencha User
    Join Date
    Aug 2009
    Posts
    7
    Vote Rating
    2
    brianpolk is on a distinguished road

      0  

    Default


    It seems that you can add one more illegal word for field names: "source"

  7. #7
    Ext JS Premium Member
    Join Date
    Oct 2007
    Posts
    85
    Vote Rating
    4
    lagnat is on a distinguished road

      0  

    Default


    Evan,

    Can you set our expectations for when we should see these fixes in the 4.1 nightly builds? I'm not seeing any changes in Reader.js. Why does it take any longer than the following nightly build?

    Thanks..

  8. #8
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,000
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Long story very short, we've got a bunch of stuff that needs to be merged into the main repo but we've got a bit of a backlog. Hopefully it should be sorted out within the next few days.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  9. #9
    Sencha User
    Join Date
    Oct 2011
    Posts
    56
    Vote Rating
    2
    geniodella is on a distinguished road

      0  

    Default Stuck with the same problem

    Stuck with the same problem


    Hi Evan ,
    is it possible to access the nightly build?
    I am stuck with the same problem.

    Thank you

  10. #10
    Sencha User
    Join Date
    Oct 2011
    Posts
    56
    Vote Rating
    2
    geniodella is on a distinguished road

      0  

    Default Was this fixed in beta 3?

    Was this fixed in beta 3?


    Hi Receive the same error even if i installed beta 3
    was this fixed?