pico-engine icon indicating copy to clipboard operation
pico-engine copied to clipboard

Installing a ruleset gives this error "SyntaxError: Identifier 'url3' has already been declared"

Open b1conrad opened this issue 2 years ago • 0 comments

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 prelude.

b1conrad avatar Mar 02 '22 20:03 b1conrad