2011-03-26 3 views
4

글로벌 함수에서 heredoc에서 베 스트링을 사용하는 데 문제가 있습니다. 런타임에서 "Exception: arg2 is not defined"오류가 발생합니다. 그것은 결코 약 arg1는 일반 문자열 안에 beesting를 사용하여 잘 것을 보여주는, 정의되어 있지 않다고 불평하지글로벌 함수 내에서 heredoc의 베시

ruleset a163x59 { 
    meta { 
    name "Beesting in heredoc" 
    description << 
     Demonstrate the error with beestings in global function heredocs 
    >> 
    author "Steve Nay" 
    logging on 
    } 

    dispatch { 
    } 

    global { 
    myFunc = function(arg1, arg2) { 
     firstString = "This is a regular string: #{arg1}. No problem there."; 
     secondString = << 
      This is a heredoc with a beesting: #{arg2}. Problem! 
     >>; 
     secondString; 
    }; 
    } 

    rule first_rule { 
    select when pageview ".*" setting() 
    pre { 
     msg = myFunc("First argument", "Second argument"); 
    } 
    notify("Testing...", msg) with sticky = true; 
    } 
} 

예를 들면 다음과 같습니다.

내가 잘못하고있는 것이 있습니까? 아니면이 버그입니까?

+1

코드 예제를 게시 할 때 보너스 포인트 (가상 어쨌든 ...). 질문에 답하는 것이 훨씬 쉽습니다! – TelegramSam

답변

3

사실 버그이지만 해결 방법이 있습니다. 이 수정 된 코드를 사용하여 기능 데프 교체 : 마지막 문 (반환 값)가 인용 beesting입니다

myFunc = function(arg1, arg2) { 
    firstString = "This is a regular string: #{arg1}. No problem there."; 
    secondString = << 
     This is a heredoc with a beesting: #{arg2}. Problem! 
    >>; 
    "#{secondString}"; 
}; 

공지있다. 이것은 heredoc 내부에서 어떤 beestings의 해결을 강제하고, 그것은 작동합니다.

이 문제는 KRL이 javascript 실행까지 베스팅 대체품을 늦게 바인딩하기 때문에 문제가 발생하지만 클로저 생성시 변수를 사용할 수 없게하는 버그가 있습니다. 인용 부호로 해상도를 강요하면이 문제가 해결됩니다.

2

나는 내 자신의 테스트에서 당신이 실제로 버그를 발견했다고 확인했습니다. 나는 그것을 접수 할 것이고 가능한 한 빨리 해결할 것입니다. 고맙습니다.

+0

굉장합니다. 그것을 돌봐 주셔서 감사합니다! –

관련 문제