[ https://issues.apache.org/jira/browse/JEXL-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16859816#comment-16859816 ]
Dmitri Blinov edited comment on JEXL-306 at 6/10/19 8:24 AM: ------------------------------------------------------------- The following script throws an exception "Undefined property y" {code:java} var x = new ("java.lang.Object"); x.y ? 1 : 2{code} I'm confused, is it a supposed behaviour? Shouldn't it return {{2}} just like in {code:java} x ? 1 : 2{code}? was (Author: dmitri_blinov): The following script throws an exception "Undefined property y" {code:java} var x = new ("java.lang.Object"); x.y ? 1 : 2{code} I'm confused, is it a supposed behaviour? Should it return {{2}} just like in {code:java} x ? 1 : 2{code} > Ternary operator ? protects also its branches from resolution errors > -------------------------------------------------------------------- > > Key: JEXL-306 > URL: https://issues.apache.org/jira/browse/JEXL-306 > Project: Commons JEXL > Issue Type: Bug > Affects Versions: 3.1 > Reporter: Dmitri Blinov > Assignee: Henri Biestro > Priority: Major > Fix For: 3.2 > > > Consider the following test case (suppose its added to IfTest) > {code:java} > @Test > public void testTernaryFail() throws Exception { > JexlEvalContext jc = new JexlEvalContext(); > JexlExpression e = JEXL.createExpression("false ? bar : quux"); > Object o; > jc.setStrict(true); > jc.setSilent(false); > try { > o = e.evaluate(jc); > Assert.fail("Should have failed"); > } catch (Exception ex) { > // OK > } > } > {code} > The expected behavior is to fail with {{undefined variable...}} because > neither {{bar}} nor {{quux}} is defined -- This message was sent by Atlassian JIRA (v7.6.3#76005)