rebcabin / masr

Meta ASR: replacement for aging ASDL
MIT License
4 stars 0 forks source link

`Integer` value in the test position of `If` statement ? #40

Open rebcabin opened 1 year ago

rebcabin commented 1 year ago

I found this in one of the stdout example. It has an Integer in the pocket. Seems too C-like.

(If ;; TODO: weird: integer value in the pocket?
         (NamedExpr
          (Var 2 a)
          (StringOrd
           (StringConstant "3" (Character 1 1 () []) )
           (Integer 4 [])
           (IntegerConstant 51 (Integer 4 [])) )
          (Integer 4 []) )
         [(=
           (Var 2 x)
           (IntegerConstant 1 (Integer 4 []))
           () )]
         []
         )

I spec it as valid for now:

(s/def ::logical-expr
  (s/or :logical-constant     ::LogicalConstant
        :logical-compare      ::LogicalCompare
        :integer-compare      ::IntegerCompare
        :real-compare         ::RealCompare
        :complex-compare      ::ComplexCompare
        :logical-binop        ::LogicalBinOp
        :logical-not          ::LogicalNot
        :cast                 ::Cast      ;; TODO check return type!
        :if-expr              ::IfExp     ;; TODO check return type!
        :named-expr           ::NamedExpr ;; TODO check return type!
        :var                  ::Var       ;; TODO check return type!
        ))
rebcabin commented 1 year ago

Ditto, this While has an integer in the test-expr pocket:


(deftest while-loop-test
  (is (s/valid?
       ::asr/WhileLoop
       (legacy
        (WhileLoop
         ()
         (NamedExpr
          (Var 2 a)
          (IntegerConstant 1 (Integer 4 []))
          (Integer 4 []))
         [(=
           (Var 2 y)
           (IntegerConstant 1 (Integer 4 []))
           ()
           )]
         )))))```
certik commented 1 year ago

I think that's a bug. It should only be logical in both if and ifexpr.