2
我試圖連接兩個8位字節和一個16字:(Z3Py)BitVec類型轉換,「那種不匹配」錯誤
from z3 import *
byte1 = BitVec('byte1', 8)
byte2 = BitVec('byte2', 8)
word = BitVec('word', 16)
s = Solver()
s.add(word==(byte1<<8) | byte2)
但我發現了錯誤:
WARNING: invalid function application, sort mismatch on argument at position 2
WARNING: (define = (bv 16) (bv 16) Bool) applied to:
word of sort (bv 16)
(bvor (bvshl byte1 bv[8:8]) byte2) of sort (bv 8)
...
z3types.Z3Exception: 'type error'
什麼是正確的方法來做到這一點?