• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function with single argument is causing an error
#1
I a function is being called that  has just one single argument, the parser reports this error:


Code:
[Aug 04 11:15:32:804318] pilight-daemon: ERROR:
... single argument')
           ^ unexpected symbol, expected a comma or closing parenthesis

This behaviour can be reproduced with this simple function:


Code:
-- Copyright (C) 2018 CurlyMo & Niek

-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.

local M = {}

function M.run(a, b)
    if a == nil or b ~= nil then
        error("TEST requires one argument")
      end
    return a
end

function M.info()
    return {
        name = "TEST",
        version = "1.0",
        reqversion = "7.0",
        reqcommit = "94"
    }
end

return M

and this config:



Code:
{
    "devices": {
        "testlabel": {
            "protocol": [ "generic_label" ],
            "id": [{
                "id": 1
            }],
            "label": "",
            "color": "black"
        }
    },
    "rules": {
        "singleargtest": {
            "rule": "IF 1 == 1 THEN label DEVICE testlabel TO TEST('test function with single argument',)",
            "active": 1
        }
    },
    "gui": {
    },
    "settings": {
        "loopback": 0,
        "standalone": 1,
        "log-level": 6,
        "pid-file": "/var/run/pilight.pid",
        "log-file": "/var/log/pilight.log",
        "webserver-enable": 1,
        "webgui-websockets": 1,
        "webserver-http-port": 54321,
        "webserver-https-port": 56662,
        "webserver-cache": 0,
        "webserver-root": "/usr/local/share/pilight/webgui",
        "gpio-platform": "raspberrypi1b1",
        "port": 5555,
        "ntp-servers": [ "0.nl.pool.ntp.org", "1.nl.pool.ntp.org", "2.nl.pool.ntp.org", "3.nl.pool.ntp.org" ]
    },
    "hardware": {
        "433gpio": {
            "sender": 0,
            "receiver": 1
        }
    },
    "registry": {
        "webgui": {
            "tabs": 1
        },
        "webserver": {
            "ssl": {
                "certificate": {
                    "secure": 0,
                    "location": "/etc/pilight/pilight.pem"
                }
            }
        },
        "pilight": {
            "version": {
                "current": "8.1.2"
            }
        }
    }
}



The validation succeeds if just a comma is added in the rule right after the first and only argument, like this:


Code:
"... THEN label DEVICE testlabel TO TEST('test function with single argument',)"

So the parser seems to be  expecting at least one comma.
 
Reply
#2
Good catch and fixed in rewrite. When travis succeeds i will it to staging.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  duplicate device names causing seqgfault in lua.c Niek 1 1,308 12-10-2018, 10:40 PM
Last Post: curlymo
  REPLACE error with installation latest staging version Niek 4 641 06-30-2018, 06:07 PM
Last Post: curlymo
  Error with new events parser Niek 28 4,615 05-07-2018, 06:25 AM
Last Post: curlymo
  Bug in str_replace function Niek 7 1,329 03-11-2018, 02:37 PM
Last Post: curlymo
  Failure if function result is longer than function itself Niek 2 802 03-03-2018, 09:15 PM
Last Post: Niek
  'FUNCTION' undeclared, v7 compilation fails Niek 10 1,719 01-08-2018, 11:54 PM
Last Post: Niek
  Error compiling pilight development Rolandd 8 3,122 09-10-2017, 12:51 PM
Last Post: tomopxs
  [Solved] Error messages in rules after update JoeC. 2 1,277 09-01-2017, 04:03 PM
Last Post: JoeC.

Forum Jump:


Browsing: 1 Guest(s)