From issues-return-80343-apmail-commons-issues-archive=commons.apache.org@commons.apache.org Mon Nov 4 11:05:02 2019 Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with SMTP id 9709919A02 for ; Mon, 4 Nov 2019 11:05:02 +0000 (UTC) Received: (qmail 31676 invoked by uid 500); 4 Nov 2019 11:05:01 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 31523 invoked by uid 500); 4 Nov 2019 11:05:01 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 31501 invoked by uid 99); 4 Nov 2019 11:05:01 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Nov 2019 11:05:01 +0000 Received: from jira-he-de.apache.org (static.172.67.40.188.clients.your-server.de [188.40.67.172]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 95BA6E2CAC for ; Mon, 4 Nov 2019 11:05:00 +0000 (UTC) Received: from jira-he-de.apache.org (localhost.localdomain [127.0.0.1]) by jira-he-de.apache.org (ASF Mail Server at jira-he-de.apache.org) with ESMTP id 1758678054F for ; Mon, 4 Nov 2019 11:05:00 +0000 (UTC) Date: Mon, 4 Nov 2019 11:05:00 +0000 (UTC) From: "Dmitri Blinov (Jira)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (JEXL-307) Variable redeclaration option MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/JEXL-307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16966560#comment-16966560 ] Dmitri Blinov commented on JEXL-307: ------------------------------------ Now the following test case fails: {code:java} @Test public void testLexical6() throws Exception { String str = "i = 0; for (var i : [1]) i; i"; JexlEngine jexl = new JexlBuilder().strict(true).lexical(true).create(); JexlScript e = jexl.createScript(str); JexlEvalContext ctxt = new JexlEvalContext(); JexlOptions options = ctxt.getEngineOptions(); // ensure errors will throw options.setLexical(true); Object o = e.execute(ctxt); Assert.assertEquals(0, o); } {code} > Variable redeclaration option > ----------------------------- > > Key: JEXL-307 > URL: https://issues.apache.org/jira/browse/JEXL-307 > Project: Commons JEXL > Issue Type: New Feature > Affects Versions: 3.1 > Reporter: Dmitri Blinov > Assignee: Henri Biestro > Priority: Minor > Fix For: 3.2 > > > As of now, JEXL allows a script writer to redeclare a local variable during script evaluation. > {code:java} > var a = 1; var a = 2;{code} > This may lead to potential errors with misspelled names and clashed variables. Checking for already defined variable is a common feature of many languages. This feature can be implemented in JEXL as an additional option of JexlFeatures class, enabled by default, thus allowing compatibility with existing code. -- This message was sent by Atlassian Jira (v8.3.4#803005)