avm2: Use correct error in toString with invalid radix

This commit is contained in:
Nathan Adams 2023-08-01 13:36:14 +02:00
parent c9c2e213bb
commit 8bbf8f4ea1
4 changed files with 21 additions and 4 deletions

View File

@ -225,7 +225,13 @@ fn to_string<'gc>(
.coerce_to_u32(activation)? as usize; .coerce_to_u32(activation)? as usize;
if radix < 2 || radix > 36 { if radix < 2 || radix > 36 {
return Err("toString can only print in bases 2 thru 36.".into()); return Err(Error::AvmError(range_error(
activation,
&format!(
"Error #1003: The radix argument must be between 2 and 36; got {radix}."
),
1003,
)?));
} }
return Ok(print_with_radix(activation, number as f64, radix)?.into()); return Ok(print_with_radix(activation, number as f64, radix)?.into());

View File

@ -321,7 +321,13 @@ fn to_string<'gc>(
.coerce_to_u32(activation)? as usize; .coerce_to_u32(activation)? as usize;
if radix < 2 || radix > 36 { if radix < 2 || radix > 36 {
return Err("toString can only print in bases 2 thru 36.".into()); return Err(Error::AvmError(range_error(
activation,
&format!(
"Error #1003: The radix argument must be between 2 and 36; got {radix}."
),
1003,
)?));
} }
return Ok(print_with_radix(activation, number, radix)?.into()); return Ok(print_with_radix(activation, number, radix)?.into());

View File

@ -224,7 +224,13 @@ fn to_string<'gc>(
.coerce_to_u32(activation)? as usize; .coerce_to_u32(activation)? as usize;
if radix < 2 || radix > 36 { if radix < 2 || radix > 36 {
return Err("toString can only print in bases 2 thru 36.".into()); return Err(Error::AvmError(range_error(
activation,
&format!(
"Error #1003: The radix argument must be between 2 and 36; got {radix}."
),
1003,
)?));
} }
return Ok(print_with_radix(activation, number as f64, radix)?.into()); return Ok(print_with_radix(activation, number as f64, radix)?.into());

View File

@ -1,2 +1 @@
num_ticks = 1 num_ticks = 1
known_failure = true