@@ -2471,122 +2471,101 @@ data RuntimeError:
2471
2471
[ ED . error: base-err]
2472
2472
end
2473
2473
end
2474
- | incompatible-units( op-name, l, r) with:
2475
- method render-fancy-reason( self, maybe-stack-loc, src-available, maybe-ast) :
2474
+ | incompatible-units( reason, u, v) with:
2475
+ # TODO Fix spacing in render-fancy-reason (and maybe render-reason)
2476
+ method render-fancy-reason( self, maybe-stack-loc, src-available, maybe-ast) block:
2477
+ base-err-msg = [ ED . para:
2478
+ ED . text( "The units " ) ,
2479
+ ED . code( ED . text( self. u)) ,
2480
+ ED . text( " and " ) ,
2481
+ ED . code( ED . text( self. v)) ,
2482
+ ED . text( " are not compatible" ) ]
2476
2483
[ ED . error:
2477
- cases ( O . Option ) maybe-stack-loc( 0 , false ) :
2484
+ cases ( O . Option ) maybe-stack-loc( 0 , true ) block :
2478
2485
| some( loc) =>
2486
+ default-err-msg = [ ED . sequence:
2487
+ ed-intro( self. reason, loc, -1 , true ) ,
2488
+ ED . cmcode( loc) ,
2489
+ base-err-msg]
2479
2490
if loc. is-builtin() :
2480
2491
[ ED . sequence:
2481
- ed-intro( self. op-name + " operation" , loc, -1 , true ) ,
2482
- [ ED . para:
2483
- ED . text( "The left side had the unit: " ) ,
2484
- ED . code( ED . text( self. l)) ] ,
2485
- [ ED . para:
2486
- ED . text( "The right side had the unit: " ) ,
2487
- ED . code( ED . text( self. r)) ] ,
2488
- [ ED . para: ED . text( "These units are not compatible" ) ] ,
2492
+ ed-intro( self. reason, loc, -1 , true ) ,
2493
+ base-err-msg,
2489
2494
please-report-bug() ]
2490
2495
else if src-available( loc) :
2491
2496
cases ( O . Option ) maybe-ast( loc) :
2492
2497
| some( ast) =>
2493
- left-loc = ast. left. l
2494
- right-loc = ast. right. l
2495
- [ ED . sequence:
2496
- ed-intro( self. op-name + " operation" , loc, -1 , true ) ,
2497
- ED . cmcode( loc) ,
2498
- [ ED . para:
2499
- ED . text( "The " ) ,
2500
- ED . highlight( ED . text( "left side" ) , [ ED . locs: left-loc] , 0 ) ,
2501
- ED . text( " had the unit:" ) ] ,
2502
- ED . code( ED . text( self. l)) ,
2503
- [ ED . para:
2504
- ED . text( "The " ) ,
2505
- ED . highlight( ED . text( "right side" ) , [ ED . locs: right-loc] , 1 ) ,
2506
- ED . text( " had the unit: " ) ] ,
2507
- ED . code( ED . text( self. r)) ,
2508
- [ ED . para: ED . text( "These units are not compatible" ) ]]
2509
- | none =>
2510
- [ ED . sequence:
2511
- ed-intro( self. op-name + " operation" , loc, -1 , true ) ,
2512
- ED . cmcode( loc) ,
2513
- [ ED . para:
2514
- ED . text( "The left side had the unit: " ) ,
2515
- ED . code( ED . text( self. l)) ] ,
2516
- [ ED . para:
2517
- ED . text( "The right side had the unit: " ) ,
2518
- ED . code( ED . text( self. r)) ] ,
2519
- [ ED . para: ED . text( "These units are not compatible" ) ]]
2498
+ cases ( Any ) ast:
2499
+ | s-op( _l, op-l, opname, l, r) =>
2500
+ left-loc = l. l
2501
+ right-loc = r. l
2502
+ [ ED . sequence:
2503
+ ed-intro( self. reason, loc, -1 , true ) ,
2504
+ ED . cmcode( loc) ,
2505
+ [ ED . para:
2506
+ ED . text( "The " ) ,
2507
+ ED . highlight( ED . text( "left side" ) , [ ED . locs: left-loc] , 0 ) ,
2508
+ ED . text( " had the unit:" ) ] ,
2509
+ ED . code( ED . text( self. u)) ,
2510
+ [ ED . para:
2511
+ ED . text( "The " ) ,
2512
+ ED . highlight( ED . text( "right side" ) , [ ED . locs: right-loc] , 1 ) ,
2513
+ ED . text( " had the unit: " ) ] ,
2514
+ ED . code( ED . text( self. v)) ,
2515
+ [ ED . para: ED . text( "These units are not compatible" ) ]]
2516
+ | else => default-err-msg
2517
+ end
2518
+ | none => default-err-msg
2520
2519
end
2521
2520
else :
2522
- [ ED . sequence:
2523
- ed-intro( self. op-name + " operation" , loc, -1 , true ) ,
2524
- ED . cmcode( loc) ,
2525
- [ ED . para:
2526
- ED . text( "The left side had the unit: " ) ,
2527
- ED . code( ED . text( self. l)) ] ,
2528
- [ ED . para:
2529
- ED . text( "The right side had the unit: " ) ,
2530
- ED . code( ED . text( self. r)) ] ,
2531
- [ ED . para: ED . text( "These units are not compatible" ) ]]
2521
+ default-err-msg
2532
2522
end
2533
2523
| none =>
2534
2524
[ ED . sequence:
2535
2525
[ ED . para:
2536
2526
ED . text( "A " ) ,
2537
- ED . code( ED . text( self. opname)) ,
2538
- ED . text( " operation errored." ) ] ,
2539
- [ ED . para:
2540
- ED . text( "The left side had the unit: " ) ,
2541
- ED . code( ED . text( self. l)) ] ,
2542
- [ ED . para:
2543
- ED . text( "The right side had the unit: " ) ,
2544
- ED . code( ED . text( self. r)) ] ,
2545
- [ ED . para: ED . text( "These units are not compatible" ) ]]
2527
+ ED . code( ED . text( self. reason)) ,
2528
+ ED . text( " errored." ) ] ,
2529
+ base-err-msg]
2546
2530
end ]
2547
2531
end ,
2548
- method render-reason( self) :
2532
+ method render-reason( self) block:
2533
+ base-err-msg = [ ED . para:
2534
+ ED . text( "The units " ) ,
2535
+ ED . code( ED . text( self. u)) ,
2536
+ ED . text( " and " ) ,
2537
+ ED . code( ED . text( self. v)) ,
2538
+ ED . text( " are not compatible" ) ]
2549
2539
[ ED . error: ED . maybe-stack-loc( 0 , false ,
2550
2540
lam ( loc) :
2551
2541
[ ED . sequence:
2552
- ed-simple-intro( self. op-name + " operation" , loc) ,
2553
- [ ED . para:
2554
- ED . text( "The left side had the unit: " ) ,
2555
- ED . code( ED . text( self. l)) ] ,
2556
- [ ED . para:
2557
- ED . text( "The right side had the unit: " ) ,
2558
- ED . code( ED . text( self. r)) ] ,
2559
- [ ED . para: ED . text( "These units are not compatible" ) ]]
2542
+ ed-simple-intro( self. reason, loc) ,
2543
+ base-err-msg]
2560
2544
end ,
2561
2545
[ ED . sequence:
2562
2546
[ ED . para:
2563
2547
ED . text( "A " ) ,
2564
- ED . code( ED . text( self. opname)) ,
2565
- ED . text( " operation errored." ) ] ,
2566
- [ ED . para:
2567
- ED . text( "The left side had the unit: " ) ,
2568
- ED . code( ED . text( self. l)) ] ,
2569
- [ ED . para:
2570
- ED . text( "The right side had the unit: " ) ,
2571
- ED . code( ED . text( self. r)) ] ,
2572
- [ ED . para: ED . text( "These units are not compatible" ) ]] ) ]
2548
+ ED . code( ED . text( self. reason)) ,
2549
+ ED . text( " errored." ) ] ,
2550
+ base-err-msg] ) ]
2573
2551
end
2574
- | invalid-unit-state( op-name, n, desc) with:
2552
+ | invalid-unit-state( opname, n, desc) with:
2553
+ # TODO: update
2575
2554
method render-fancy-reason( self, maybe-stack-loc, src-available, maybe-ast) :
2576
2555
[ ED . error:
2577
2556
cases ( O . Option ) maybe-stack-loc( 0 , false ) :
2578
2557
| some( loc) =>
2579
2558
if loc. is-builtin() :
2580
2559
[ ED . sequence:
2581
- ed-intro( self. op-name + " function" , loc, -1 , true ) ,
2560
+ ed-intro( self. opname + " function" , loc, -1 , true ) ,
2582
2561
[ ED . para:
2583
2562
ED . code( ED . text( tostring( self. n))) ,
2584
2563
ED . text( " is an invalid argument because: " ) ,
2585
2564
ED . text( self. desc) ] ,
2586
2565
please-report-bug() ]
2587
2566
else if src-available( loc) :
2588
2567
[ ED . sequence:
2589
- ed-intro( self. op-name + " function" , loc, -1 , true ) ,
2568
+ ed-intro( self. opname + " function" , loc, -1 , true ) ,
2590
2569
ED . cmcode( loc) ,
2591
2570
[ ED . para:
2592
2571
ED . code( ED . text( tostring( self. n))) ,
@@ -2596,7 +2575,7 @@ data RuntimeError:
2596
2575
| none =>
2597
2576
[ ED . sequence:
2598
2577
[ ED . para:
2599
- ED . text( "The " + self. op-name + " function failed." ) ] ,
2578
+ ED . text( "The " + self. opname + " function failed." ) ] ,
2600
2579
[ ED . para:
2601
2580
ED . code( ED . text( tostring( self. n))) ,
2602
2581
ED . text( " is an invalid argument because: " ) ,
@@ -2607,14 +2586,14 @@ data RuntimeError:
2607
2586
[ ED . error: ED . maybe-stack-loc( 0 , false ,
2608
2587
lam ( loc) :
2609
2588
[ ED . sequence:
2610
- ed-simple-intro( self. op-name + " function" , loc) ,
2589
+ ed-simple-intro( self. opname + " function" , loc) ,
2611
2590
[ ED . para:
2612
2591
ED . code( ED . text( tostring( self. n))) ,
2613
2592
ED . text( " is an invalid argument because: " ) ,
2614
2593
ED . text( self. desc) ]]
2615
2594
end ,
2616
2595
[ ED . sequence:
2617
- [ ED . para: ED . text( "The " + self. op-name + " function failed." ) ] ,
2596
+ [ ED . para: ED . text( "The " + self. opname + " function failed." ) ] ,
2618
2597
[ ED . para:
2619
2598
ED . code( ED . text( tostring( self. n))) ,
2620
2599
ED . text( " is an invalid argument because: " ) ,
0 commit comments