Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIx regression with member tag of enum not being checked on assigment #164

Merged

Conversation

Arkshine
Copy link
Member

This fixes regression introduced in AMXX 1.60: a105bc7

Original fix removes tag mismatch warning in such situation:

enum GABEGG
{
    GABEN_CONST_1,
    GABEN_CONST_2,
};

new Float:MyArray_2[GABEGG];

MyArray_2[GABEN_CONST_1] = 42.0; // no more warning

But introduced a regression when tagged members of enum is used.
Tag check is processed with MyArray instead of member tag.

enum GABEN
{
    MyTag:m_Gaben_1,
    Float:m_Gaben_2,
    Regex:m_Gaben_3,
    bool:m_Gaben_4,
    m_Gaben_5
};

new MyArray[GABEN];

With original fix, member tag is ignored and coder has to rely on _: to untag before:

MyArray[m_Gaben_1] = MyTag:42;                      // warning
MyArray[m_Gaben_2] = _:42.0;                        
MyArray[m_Gaben_2] = 42.0;                          // warning
MyArray[m_Gaben_2] = 42;                            // no warning, it should have one
MyArray[m_Gaben_3] = _:regex_compile("Something");  
MyArray[m_Gaben_3] = regex_compile("Something");    // warning
MyArray[m_Gaben_3] = Regex:42;                      // warning
MyArray[m_Gaben_4] = true;                          
MyArray[m_Gaben_5] = 42; 

With new fix, trick with _: is kept, while member tag is now checked:

MyArray[m_Gaben_1] = MyTag:42;                      
MyArray[m_Gaben_2] = _:42.0;                        // no warning for compatibility
MyArray[m_Gaben_2] = 42.0;                          
MyArray[m_Gaben_2] = 42;                            // warning, expects a Float
MyArray[m_Gaben_3] = _:regex_compile("Something");  // no warning for compatibility
MyArray[m_Gaben_3] = regex_compile("Something");   
MyArray[m_Gaben_3] = Regex:42;                      
MyArray[m_Gaben_4] = true;                          
MyArray[m_Gaben_5] = 42;  

MyArray_2[GABEN_CONST_1] = 42.0;                    // still no warning       

I hope I did not forget something and that it looks enough sane.
Tell me your thoughts David.

@@ -1201,8 +1225,10 @@ static int hier2(value *lval)
return FALSE;
case tLABEL: /* tagname override */
tag=pc_addtag(st);
forceuntag=(*st == '_' && !tag); /* forced to be untagged with _: */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defense-in-depth is fine in this code, but just the !tag should be enough. Only '_' should resolve to 0.

Arkshine added a commit that referenced this pull request Dec 13, 2014
FIx regression with member tag of enum not being checked on assigment
@Arkshine Arkshine merged commit 1df58d6 into alliedmodders:master Dec 13, 2014
@Arkshine Arkshine deleted the fix/regression-member-tag-of-enum branch December 13, 2014 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants