[asterisk-dev] [Code Review] 3627: Update extensions.lua.sample with naming conflict guidance.

George Joseph reviewboard at asterisk.org
Tue Jun 17 20:29:14 CDT 2014


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/3627/
-----------------------------------------------------------

Review request for Asterisk Developers and rnewton.


Bugs: asterisk-23844
    https://issues.asterisk.org/jira/browse/asterisk-23844


Repository: Asterisk


Description
-------

The sample extensions.lua was causing pbx_lua to fail to load when parsing 'app.goto("default", "s", 1)' because in Lua 5.2, 'goto' is now a reserved word.  Added the following guidance to extensions.lua.sample and changed 'app.goto("default", "s", 1)' to 'app.['goto']("default", "s", 1)'.  

-- Note about naming conflicts:
-- Lua allows you to refer to table entries using the '.' notation,
-- I.E. app.goto(something), only if the entry doesn't conflict with an Lua
-- reserved word.  In the 'goto' example, with Lua 5.1 or earlier, 'goto' is
-- not a reserved word so you'd be calling the Asterisk dialplan application
-- 'goto'.  Lua 5.2 however, introduced the 'goto' control statement which
-- makes 'goto' a reserved word.  This casues the interpreter to fail parsing
-- the file and pbx_lua.so will fail to load.  The same applies to any use of
-- Lua tables including extensions, channels and any tables you create.
--
-- There are two ways around this:  Since Lua is case-sensitive, you can use
-- capitalized names, I.E. app.Goto(something) to refer to the Asterisk apps,
-- functions, etc. Or you can use the full syntax, I.E. app["goto"](something).
-- Both syntaxes are backwards compatible with earlier Lua versions.  To make
-- your Lua dialplans easier to maintain and to reduce the chance of future
-- conflicts you may want to use the app["goto"](something) syntax for all
-- table accesses.
--

This patch will merge through to 11, 12 and trunk.

The wiki needs to be update with the same info.


Diffs
-----

  branches/1.8/configs/extensions.lua.sample 416556 

Diff: https://reviewboard.asterisk.org/r/3627/diff/


Testing
-------

Made sure extensions.lua now loads correctly.


Thanks,

George Joseph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20140618/ef4ce055/attachment.html>


More information about the asterisk-dev mailing list