Asterisk 13 Gosub AEL warning

Hi all,
I`m trying to use a subroutine as I have some code that I have to repeat it in every IVR.

context mySubroutine {

        s=>{
            /*   .... some logic here to determine asError and gotoLabel variables ... . */
            if("${asError}"!=""){
                Noop("${asError} ${SYSTEMNAME}");
                Return("");
            }

            if ( "${gotoLabel}"!=""){
                Return(${gotoLabel});
            }
            else{
                Noop("No label for ${CHANNEL(name)} ${SYSTEMNAME}");
            }

            Return("");
        };
};

As you can see I need to return something from this subroutine.
This is the code that calls the subroutine:

context myContext {

            Gosub(mySubroutine,s,1(someParamHere));

            if ( "${GOSUB_RETVAL}"!=""){
                goto ${GOSUB_RETVAL};
            }
}

Everything is working fine but when reload ael I get warnings like this:

Warning: file xxx line 8-8: application call to Gosub affects flow of control, and needs to be re-written using AEL if, while, goto, etc. keywords instead!

I have read about this and it seems to be a known Bug since asterisk 1.6, that appears as resolved. Any idea why I still have these warnings in asterisk13?

Most people here, possibly all the regulars, use extensions.conf, not extensions.ael, and are not familiar with AEL syntax.

Cant you use a macro…?

https://wiki.asterisk.org/wiki/display/AST/AEL+Macros

Cant you use a macro…?

Seems that macro is deprecated.

Macros are very similar in function to the Gosub application which deprecates Macro. This information is here for historical purposes and you should really use Gosub wherever you would have previously used Macro.

AEL complies to a gosub, even if you use its version of a macro.

The warning is still there, see the source code of the asterisk 21 release:

You should use the macro AEL construct for your mySubroutine. AEL generates a dialplan context from your mySubroutine AEL macro. Then you can call this AEL macro by &mySubroutine(...) in your myContext context. AEL parser generates a Gosub call to that context, so the deprecated Macro() dialplan application is not used:

macro mySubroutine(theParam) {   // <-------------- it's an ael macro

            /*   .... some logic here to determine asError and gotoLabel variables ... . */
            if("${asError}"!=""){
                Noop("${asError} ${SYSTEMNAME}");
                Return("");
            }

            if ( "${gotoLabel}"!=""){
                Return(${gotoLabel});
            }
            else{
                Noop("No label for ${CHANNEL(name)} ${SYSTEMNAME}");
            }

            Return("");
};

context myContext {
        s => {

            &mySubroutine(someParamHere);  // <------ call ael macro

            if ( "${GOSUB_RETVAL}"!=""){
                goto ${GOSUB_RETVAL};
            }
        }
}

This will generate the following dial plan:



[mySubroutine]
exten => ~~s~~,1,Set(LOCAL(theParam)=${ARG1})
exten => ~~s~~,2,GotoIf($["${asError}"!=""]?3:5)
exten => ~~s~~,3,Noop("${asError} ${SYSTEMNAME}")
exten => ~~s~~,4,Return("")
exten => ~~s~~,5,NoOp(Finish if_mySubroutine_1)
exten => ~~s~~,6,GotoIf($["${gotoLabel}"!=""]?7:9)
exten => ~~s~~,7,Return(${gotoLabel})
exten => ~~s~~,8,Goto(10)
exten => ~~s~~,9,Noop("No label for ${CHANNEL(name)} ${SYSTEMNAME}")
exten => ~~s~~,10,NoOp(Finish if_mySubroutine_2)
exten => ~~s~~,11,Return("")
exten => ~~s~~,12,Return()


[myContext]
exten => s,1,Gosub(mySubroutine,~~s~~,1(someParamHere))
exten => s,2,GotoIf($["${GOSUB_RETVAL}"!=""]?3:4)
exten => s,3,Goto(${GOSUB_RETVAL})
exten => s,4,NoOp(Finish if_myContext_3)

To get this dialplan output I use the aelparse tool:

aelparse -d -w && cat extensions.conf.aeldump