pawn-lang / compiler

Pawn compiler for SA-MP with bug fixes and new features - runs on Windows, Linux, macOS
Other
307 stars 72 forks source link

Fix return array size specifications being ignored in operator declarations #686

Open Daniel-Cortez opened 3 years ago

Daniel-Cortez commented 3 years ago

What this PR does / why we need it:

Fixes return array size specifications being silently ignored in new-style operator declarations (see #685) and makes the compiler treat such specifications as errors.

Which issue(s) this PR fixes:

Fixes #685

What kind of pull this is:

Additional Documentation:

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity.

Y-Less commented 2 years ago

@Daniel-Cortez Just to tell you (don't know a better way to contact you), I'm going to go through the backlog this week and try release 3.10.11 on 08/02, since it is exactly 2 years since 3.10.10. Seems appropriate.

DEntis-T commented 2 years ago

Did you mean 3.11? 3.10.11 just seems kind of wrong to me...

Y-Less commented 2 years ago

@DEntis-T: No

@Daniel-Cortez:

1>Running gh_685... FAILED
1>Test gh_685 failed for the following reason: Error output didn't match
1>
1>Expected errors:
1>
1>gh_685.pwn(1): error 010: invalid function or declaration
1>gh_685.pwn(2): error 010: invalid function or declaration
1>
1>Actual errors:
1>
1>gh_685.pwn(1): error 010: invalid function or declaration
1>gh_685.pwn(2): error 010: invalid function or declaration
1>Assertion failed: parent_sym->ident==iREFARRAY, file C:\Users\Alex\Documents\SA-MP\pawn\source\compiler\sc2.c, line 3229
1>

Which is:

    case iREFARRAY:
      /* a global iREFARRAY symbol is the return value of a function: delete
       * this only if "globals" must be deleted; other iREFARRAY instances
       * (locals) are also deleted
       */
      mustdelete=(sym->vclass==sGLOBAL) ? delete_functions : TRUE;
      for (parent_sym=sym->parent; parent_sym!=NULL && parent_sym->ident!=iFUNCTN; parent_sym=parent_sym->parent)
        assert(parent_sym->ident==iREFARRAY);
      assert(parent_sym==NULL || (parent_sym->ident==iFUNCTN && parent_sym->parent==NULL));
      if (sym->vclass==sGLOBAL) {
        assert(parent_sym!=NULL && parent_sym->ident==iFUNCTN);
        if ((parent_sym->usage & uNATIVE)!=0) {
          /* native functions aren't preserved (see the comment under the
           * 'iFUNCTN' case below), so the array must be deleted as well */
          mustdelete=TRUE;
        } /* if */
      } /* if */
      break;
        assert(parent_sym->ident==iREFARRAY);
Daniel-Cortez commented 2 years ago

@Daniel-Cortez Just to tell you (don't know a better way to contact you), I'm going to go through the backlog this week and try release 3.10.11 on 08/02, since it is exactly 2 years since 3.10.10. Seems appropriate.

@Y-Less Well, I tried to contact you via Discord, sent you a friend request a few months ago, but you didn't answer. Anyway, is https://github.com/openmultiplayer/compiler the actual repo for the compiler now? If so, should I move my PRs there?