el-spec
  1. el-spec
  2. EL_SPEC-2

Backwards Compatibility Issue with Binary Operator "+"

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Labels:
      None
    • Environment:

      N/A

      Description

      In section 1.7.1 Binary Operators of the Expression Language Specification Version 3.0, there has been an additional Rule added that causes a Backwards compatibility issue.

      From version 3.0 of the specification its states the following:

      1.7.1 Binary operators - A {+,-,*} B
      ■ If the operator is a +, and either A or B is a String, then + is a string concatenation <---- This is the newly added Rule.
      operator.
      ■ If A and B are null, return (Long)0
      ■ If A or B is a BigDecimal, coerce both to BigDecimal and then:
      ■ If operator is +, return A.add(B)
      ■ If operator is -, return A.subtract(B)
      ■ If operator is *, return A.multiply(B)
      ■ If A or B is a Float, Double, or String containing ., e, or E: <---------- This Rule never gets reached now !!!!!
      ■ If A or B is BigInteger, coerce both A and B to BigDecimal and apply
      operator.
      ■ Otherwise, coerce both A and B to Double and apply operator
      ■ If A or B is BigInteger, coerce both to BigInteger and then:
      ■ If operator is +, return A.add(B)
      ■ If operator is -, return A.subtract(B)
      ■ If operator is *, return A.multiply(B)
      ■ Otherwise coerce both A and B to Long and apply operator
      ■ If operator results in exception, error

      The problem with the newly added rule at the top of the order is that they " If A or B is a Float, Double, or String containing ., e, or E:" Never gets a chance to be parsed. This breaks backwards compatibility.

        Activity

        Hide
        dougd added a comment - - edited

        Maybe we can do something like this.

        1.7.1 Binary operators - A {+,-,*} B
        ■ If the operator is a +, and either A or B is a String:
        ■ If A or B is a Float, Double, or String containing ., e, or E:
        ■ If A or B is BigInteger, coerce both A and B to BigDecimal and apply operator.
        ■ Otherwise, coerce both A and B to Double and apply operator
        ■ Otherwise + is a string concatenation operator.
        ■ If A and B are null, return (Long)0
        ■ If A or B is a BigDecimal, coerce both to BigDecimal and then:
        ■ If operator is +, return A.add(B)
        ■ If operator is -, return A.subtract(B)
        ■ If operator is *, return A.multiply(B)
        ■ If A or B is BigInteger, coerce both to BigInteger and then:
        ■ If operator is +, return A.add(B)
        ■ If operator is -, return A.subtract(B)
        ■ If operator is *, return A.multiply(B)
        ■ Otherwise coerce both A and B to Long and apply operator
        ■ If operator results in exception, error

        Show
        dougd added a comment - - edited Maybe we can do something like this. 1.7.1 Binary operators - A {+,-,*} B ■ If the operator is a +, and either A or B is a String: ■ If A or B is a Float, Double, or String containing ., e, or E: ■ If A or B is BigInteger, coerce both A and B to BigDecimal and apply operator. ■ Otherwise, coerce both A and B to Double and apply operator ■ Otherwise + is a string concatenation operator. ■ If A and B are null, return (Long)0 ■ If A or B is a BigDecimal, coerce both to BigDecimal and then: ■ If operator is +, return A.add(B) ■ If operator is -, return A.subtract(B) ■ If operator is *, return A.multiply(B) ■ If A or B is BigInteger, coerce both to BigInteger and then: ■ If operator is +, return A.add(B) ■ If operator is -, return A.subtract(B) ■ If operator is *, return A.multiply(B) ■ Otherwise coerce both A and B to Long and apply operator ■ If operator results in exception, error
        Hide
        kchung added a comment -

        The symbol + is no longer used as a concatenation operator in PFD.

        Show
        kchung added a comment - The symbol + is no longer used as a concatenation operator in PFD.

          People

          • Assignee:
            Unassigned
            Reporter:
            dougd
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: