[asterisk-bugs] [JIRA] (ASTERISK-23844) load of pbx_lua fails on sample extensions.lua

George Joseph (JIRA) noreply at issues.asterisk.org
Tue Jun 17 12:49:56 CDT 2014


    [ https://issues.asterisk.org/jira/browse/ASTERISK-23844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=219561#comment-219561 ] 

George Joseph commented on ASTERISK-23844:
------------------------------------------

The problem stems from the use of 'app.goto' which is meant to run the Asterisk goto application.  This works in Lua < 5.2 because there was no goto stament in Lua <5.2 but Lua 5.2 added the Lua goto statement so now the Lua interpreter is seeing an unquoted reference to goto and trying to parse it as an Lua statement.  The same issue would happen for any Asterisk application that has the same name as an Lua reserved word.  There's no code fix for this...it's just how the Lua interpreter works (and rightly so, I believe).

Fortunately, there's a way around it by using a different syntax in the *.lua files.  
Instead of...
   app.goto("local_default",1180,1)

you could use...
   app.Goto("local_default",1180,1)
   app.GOTO("local_default",1180,1)
The capitalization makes Lua not recognize it as a reserved word

or more correctly...
   app['goto']("local_default",1180,1)

The alternate syntaxes are backwards compatible and work for all applications.

So my suggestion would be to change the sample config file to use the app['appname'] syntax and update the wiki pages as well.

I can update the sample ( 1.8, 11, 12, trunk) but I don't think I can update the wiki page.




> load of pbx_lua fails on sample extensions.lua
> ----------------------------------------------
>
>                 Key: ASTERISK-23844
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-23844
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>    Affects Versions: SVN, 12.3.0
>            Reporter: Rusty Newton
>            Assignee: George Joseph
>            Severity: Trivial
>
> {noformat}
> *CLI> module load pbx_lua.so
> Unable to load module pbx_lua.so
> Command 'module load pbx_lua.so' failed.
> [Jun  9 17:17:07] ERROR[19906]: pbx_lua.c:1635 load_or_reload_lua_stuff: Error loading extensions.lua: [string "extensions.lua"]:147: <name> expected near 'goto'
> {noformat}
> and the line:
> {noformat}
>                 ["1000"] = function()
>                         app.goto("demo", "s", 1)
>                 end;
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list