Recover from integer parsing failure
ASPL 0.7.0 · Current release
Complete supplied source, preparation, and checked ASPL 0.7.0 outcomes.
On this page
Purpose and preparation
Browser and native, ASPL 0.7.0. Send 256 then 41. The u8 parse returns number-out-of-range; the i64 parse succeeds and prints 42. Status is 0.
See the current reference. No source module or external library is required.
Arabic source
This supplied complete source opens a new draft. Prepare the declared inputs/files in that draft, then select Run explicitly.
Execution: Browser and native · ASPL 0.7.0
- No prior knowledge is required to open and check it.
Input lines: ["256","41"]
دالة ابدأ_الرئيسية() -> ص64 {
اطبع("first: ").
دع سيئ: نتيجة<ط8> = حلل_ط8(اقرأ_سطر()).
إذا (سيئ::نجاح) {
أرجع 1.
}
اطبع(سيئ::الخطأ::الرمز).
اطبع("\سsecond: ").
دع جيد: نتيجة<ص64> = حلل_ص64(اقرأ_سطر()).
إذا (جيد::نجاح) {
إذا (نسق_ص64(-9223372036854775808) لا يطابق "-9223372036854775808") { أرجع 2. }
اطبع(نسق_ص64(جيد::قيمة + 1)).
اطبع("\س").
أرجع 0.
}
أرجع 3.
}
Expected outcomes
{
"browser": {
"check": "success",
"class": "success",
"output": "first: number-out-of-range\nsecond: 42\n",
"processStatus": 0
},
"native": {
"check": 0,
"status": 0,
"output": "first: number-out-of-range\nsecond: 42\n"
}
}English source
This supplied complete source opens a new draft. Prepare the declared inputs/files in that draft, then select Run explicitly.
Execution: Browser and native · ASPL 0.7.0
- No prior knowledge is required to open and check it.
Input lines: ["256","41"]
fn start_main() -> i64 {
print("first: ");
let invalid: result<u8> = parse_u8(read_line());
if (invalid::ok) {
return 1;
}
print(invalid::error::code);
print("\nsecond: ");
let valid: result<i64> = parse_i64(read_line());
if (valid::ok) {
if (format_i64(-9223372036854775808) not match "-9223372036854775808") { return 2; }
print(format_i64(valid::value + 1));
print("\n");
return 0;
}
return 3;
}
Expected outcomes
{
"browser": {
"check": "success",
"class": "success",
"output": "first: number-out-of-range\nsecond: 42\n",
"processStatus": 0
},
"native": {
"check": 0,
"status": 0,
"output": "first: number-out-of-range\nsecond: 42\n"
}
}Mixed source
This supplied complete source opens a new draft. Prepare the declared inputs/files in that draft, then select Run explicitly.
Execution: Browser and native · ASPL 0.7.0
- No prior knowledge is required to open and check it.
Input lines: ["256","41"]
fn ابدأ_الرئيسية() -> ص64 {
اطبع("first: ").
let سيئ: نتيجة<u8> = parse_u8(اقرأ_سطر()).
إذا (سيئ::ok) { أرجع 1. }
print(سيئ::الخطأ::code).
print("\nsecond: ").
دع جيد: result<ص64> = حلل_ص64(read_line()).
if (جيد::نجاح) {
إذا (format_i64(-9223372036854775808) not match "-9223372036854775808") { return 2. }
اطبع(نسق_ص64(جيد::value + 1)).
print("\n").
أرجع 0.
}
return 3.
}
Expected outcomes
{
"browser": {
"check": "success",
"class": "success",
"output": "first: number-out-of-range\nsecond: 42\n",
"processStatus": 0
},
"native": {
"check": 0,
"status": 0,
"output": "first: number-out-of-range\nsecond: 42\n"
}
}Check the result
The source cards show the catalog's exact inputs and outcomes. Locale changes do not translate the supplied source. Download retains original source bytes.