pico-engine
pico-engine copied to clipboard
Installing a ruleset gives this error "SyntaxError: Identifier 'url3' has already been declared"
But running it through krl-compiler --verify
didn't report an error.
Trying it without the --verify
flag... No error reported, but the generated Javascript code includes
var url3 = $state.setting["url"];
this.rule.state = Object.assign({}, $state, { "setting": {} });
const url3 = await get1($ctx, [...]);
so the error isn't detected until the JS compiled code is brought into the pico engine in order to evaluate the global
block.
It is a KRL programmer error! But it would be nice if the krl-compiler
could catch it!
rule installApp {
select when byu_hr_manage_apps new_app
url re#(.+)# setting(url)
pre {
url = event:attr("_headers").get("referer")
}
if url then send_directive("_redirect",{"url":url})
fired {
raise wrangler event "install_ruleset_request"
attributes {"url":url,"tx":meta:txnId}
}
}
Meanwhile, it can be easily fixed in KRL by not re-using a variable name from setting
within the pre
lude.