@@ -1240,15 +1240,16 @@ impl QASMEngine {
12401240 match name {
12411241 "RNGseed" => {
12421242 if args. len ( ) != 1 {
1243- return Err ( PecosError :: ParseInvalidExpression (
1244- "Expected a single seed for RNGseed. Received {args.len()}" . to_string ( ) ,
1245- ) ) ;
1243+ return Err ( PecosError :: ParseInvalidExpression ( format ! (
1244+ "RNGseed expects exactly 1 argument (seed), got {}" ,
1245+ args. len( )
1246+ ) ) ) ;
12461247 }
12471248 let seed: u64 = match & args[ 0 ] {
12481249 Expression :: Integer ( bit_vec) => bit_vec. load ( ) ,
12491250 _ => {
12501251 return Err ( PecosError :: ParseInvalidExpression (
1251- "Invalid seed for RNGseed. Expected u64 " . to_string ( ) ,
1252+ "RNGseed expects a u64 as its argument " . to_string ( ) ,
12521253 ) ) ;
12531254 }
12541255 } ;
@@ -1258,15 +1259,16 @@ impl QASMEngine {
12581259 }
12591260 "RNGindex" => {
12601261 if args. len ( ) != 1 {
1261- return Err ( PecosError :: ParseInvalidExpression (
1262- "Expected a single index for RNGseed. Received {args.len()}" . to_string ( ) ,
1263- ) ) ;
1262+ return Err ( PecosError :: ParseInvalidExpression ( format ! (
1263+ "RNGindex expects exactly 1 argument (index), got {}" ,
1264+ args. len( )
1265+ ) ) ) ;
12641266 }
12651267 let idx: u64 = match & args[ 0 ] {
12661268 Expression :: Integer ( bit_vec) => bit_vec. load ( ) ,
12671269 _ => {
12681270 return Err ( PecosError :: ParseInvalidExpression (
1269- "Invalid idx for RNGindex. Expected u64 " . to_string ( ) ,
1271+ "RNGindex expects a u64 as its argument " . to_string ( ) ,
12701272 ) ) ;
12711273 }
12721274 } ;
@@ -1275,15 +1277,16 @@ impl QASMEngine {
12751277 }
12761278 "RNGbound" => {
12771279 if args. len ( ) != 1 {
1278- return Err ( PecosError :: ParseInvalidExpression (
1279- "Expected a single bound for RNGbound. Received {args.len()}" . to_string ( ) ,
1280- ) ) ;
1280+ return Err ( PecosError :: ParseInvalidExpression ( format ! (
1281+ "RNGbound expects exactly 1 argument (bound), got {}" ,
1282+ args. len( )
1283+ ) ) ) ;
12811284 }
12821285 let ubound: u32 = match & args[ 0 ] {
12831286 Expression :: Integer ( bit_vec) => bit_vec. load ( ) ,
12841287 _ => {
12851288 return Err ( PecosError :: ParseInvalidExpression (
1286- "Invalid idx for RNGindex. Expected u64 " . to_string ( ) ,
1289+ "RNGbound expects a u32 as its argument " . to_string ( ) ,
12871290 ) ) ;
12881291 }
12891292 } ;
@@ -1292,10 +1295,12 @@ impl QASMEngine {
12921295 }
12931296 "RNGnum" => {
12941297 if !args. is_empty ( ) {
1295- return Err ( PecosError :: ParseInvalidExpression (
1296- "RNGnum receives no arguments. Received {args.len()}" . to_string ( ) ,
1297- ) ) ;
1298+ return Err ( PecosError :: ParseInvalidExpression ( format ! (
1299+ "RNGnum expects no arguments, got {}" ,
1300+ args. len( )
1301+ ) ) ) ;
12981302 }
1303+
12991304 let rng_num = self . rng_model . rng_num ( ) ;
13001305
13011306 // convert random number to bitvec
@@ -1305,9 +1310,9 @@ impl QASMEngine {
13051310 }
13061311 Ok ( ExpressionValue :: BitVec ( bitvec) )
13071312 }
1308- _ => Err ( PecosError :: ParseInvalidExpression (
1309- "Invalid RNG function '{name}'" . to_string ( ) ,
1310- ) ) ,
1313+ _ => Err ( PecosError :: ParseInvalidExpression ( format ! (
1314+ "Unknown RNG function '{name}'"
1315+ ) ) ) ,
13111316 }
13121317 }
13131318
0 commit comments