QuantumBFS / YaoLang.jl

YaoLang: The next DSL for Yao and quantum programs.
https://yaoquantum.org/YaoLang.jl/dev/
Apache License 2.0
31 stars 6 forks source link

Bugs in the QASM parser #63

Closed ChenZhao44 closed 3 years ago

ChenZhao44 commented 3 years ago

The - is not perfectly supported.

julia> qasm"""OPENQASM 2.0;
       qreg a[1];
       U(0, -1.0/2*3, 0) a;
       """
ERROR: MethodError: no method matching -(::Expr)
Closest candidates are:
  -(::Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}) at int.jl:85
  -(::T, ::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} at int.jl:86
  -(::Union{UInt16, UInt32, UInt64, UInt8}, ::BigInt) at gmp.jl:531
  ...
Stacktrace:
 [1] parse_exp(stmt::YaoLang.Compiler.QASM.Parse.Struct_neg)
   @ YaoLang.Compiler.QASM ~/.julia/dev/YaoLang/src/compiler/qasm.jl:526
 [2] parse(m::Module, record::YaoLang.Compiler.QASM.RegisterRecord, stmt::YaoLang.Compiler.QASM.Parse.Struct_u)
   @ YaoLang.Compiler.QASM ~/.julia/dev/YaoLang/src/compiler/qasm.jl:414
 [3] parse(m::Module, ast::YaoLang.Compiler.QASM.Parse.Struct_mainprogram)
   @ YaoLang.Compiler.QASM ~/.julia/dev/YaoLang/src/compiler/qasm.jl:327
 [4] parse(m::Module, source::String)
   @ YaoLang.Compiler.QASM ~/.julia/dev/YaoLang/src/compiler/qasm.jl:307
 [5] @qasm_str(__source__::LineNumberNode, __module__::Module, source::String)
   @ YaoLang.Compiler.QASM ~/.julia/dev/YaoLang/src/compiler/qasm.jl:592
 [6] eval
   @ ./boot.jl:360 [inlined]
Roger-luo commented 3 years ago

this should be resolved now.