@@ -2475,15 +2475,94 @@ data RuntimeError:
2475
2475
end
2476
2476
| incompatible-units( op-name, l, r) with:
2477
2477
method render-fancy-reason( self, maybe-stack-loc, src-available, maybe-ast) :
2478
- self. render-reason()
2478
+ [ ED . error:
2479
+ cases ( O . Option ) maybe-stack-loc( 0 , false ) :
2480
+ | some( loc) =>
2481
+ if loc. is-builtin() :
2482
+ [ ED . sequence:
2483
+ ed-intro( self. op-name + " operation" , loc, -1 , true ) ,
2484
+ [ ED . para:
2485
+ ED . text( "The left side had the unit: " ) ,
2486
+ ED . code( ED . text( self. l)) ] ,
2487
+ [ ED . para:
2488
+ ED . text( "The right side had the unit: " ) ,
2489
+ ED . code( ED . text( self. r)) ] ,
2490
+ [ ED . para: ED . text( "These units are not compatible" ) ] ,
2491
+ please-report-bug() ]
2492
+ else if src-available( loc) :
2493
+ cases ( O . Option ) maybe-ast( loc) :
2494
+ | some( ast) =>
2495
+ left-loc = ast. left. l
2496
+ right-loc = ast. right. l
2497
+ [ ED . sequence:
2498
+ ed-intro( self. op-name + " operation" , loc, -1 , true ) ,
2499
+ ED . cmcode( loc) ,
2500
+ [ ED . para:
2501
+ ED . text( "The " ) ,
2502
+ ED . highlight( ED . text( "left side" ) , [ ED . locs: left-loc] , 0 ) ,
2503
+ ED . text( " had the unit:" ) ] ,
2504
+ ED . code( ED . text( self. l)) ,
2505
+ [ ED . para:
2506
+ ED . text( "The " ) ,
2507
+ ED . highlight( ED . text( "right side" ) , [ ED . locs: right-loc] , 1 ) ,
2508
+ ED . text( " had the unit: " ) ] ,
2509
+ ED . code( ED . text( self. r)) ,
2510
+ [ ED . para: ED . text( "These units are not compatible" ) ]]
2511
+ | none => ED . text( "TODO" )
2512
+ end
2513
+ else :
2514
+ [ ED . sequence:
2515
+ ed-intro( self. op-name + " operation" , loc, -1 , true ) ,
2516
+ ED . cmcode( loc) ,
2517
+ [ ED . para:
2518
+ ED . text( "The left side had the unit: " ) ,
2519
+ ED . code( ED . text( self. l)) ] ,
2520
+ [ ED . para:
2521
+ ED . text( "The right side had the unit: " ) ,
2522
+ ED . code( ED . text( self. r)) ] ,
2523
+ [ ED . para: ED . text( "These units are not compatible" ) ]]
2524
+ end
2525
+ | none =>
2526
+ [ ED . sequence:
2527
+ [ ED . para:
2528
+ ED . text( "A " ) ,
2529
+ ED . code( ED . text( self. opname)) ,
2530
+ ED . text( " operation errored." ) ] ,
2531
+ [ ED . para:
2532
+ ED . text( "The left side had the unit: " ) ,
2533
+ ED . code( ED . text( self. l)) ] ,
2534
+ [ ED . para:
2535
+ ED . text( "The right side had the unit: " ) ,
2536
+ ED . code( ED . text( self. r)) ] ,
2537
+ [ ED . para: ED . text( "These units are not compatible" ) ]]
2538
+ end ]
2479
2539
end ,
2480
2540
method render-reason( self) :
2481
- [ ED . error:
2482
- [ ED . para:
2483
- ED . text( "The " + self. op-name + " operation failed due to incompatible units. " ) ,
2484
- ED . text( tostring( self. l)) ,
2485
- ED . text( " is not compatible with " ) ,
2486
- ED . text( tostring( self. r)) ]]
2541
+ [ ED . error: ED . maybe-stack-loc( 0 , false ,
2542
+ lam ( loc) :
2543
+ [ ED . sequence:
2544
+ ed-simple-intro( self. op-name + " operation" , loc) ,
2545
+ ED . cmcode( loc) ,
2546
+ [ ED . para:
2547
+ ED . text( "The left side had the unit: " ) ,
2548
+ ED . code( ED . text( self. l)) ] ,
2549
+ [ ED . para:
2550
+ ED . text( "The right side had the unit: " ) ,
2551
+ ED . code( ED . text( self. r)) ] ,
2552
+ [ ED . para: ED . text( "These units are not compatible" ) ]]
2553
+ end ,
2554
+ [ ED . sequence:
2555
+ [ ED . para:
2556
+ ED . text( "A " ) ,
2557
+ ED . code( ED . text( self. opname)) ,
2558
+ ED . text( " operation errored." ) ] ,
2559
+ [ ED . para:
2560
+ ED . text( "The left side had the unit: " ) ,
2561
+ ED . code( ED . text( self. l)) ] ,
2562
+ [ ED . para:
2563
+ ED . text( "The right side had the unit: " ) ,
2564
+ ED . code( ED . text( self. r)) ] ,
2565
+ [ ED . para: ED . text( "These units are not compatible" ) ]] ) ]
2487
2566
end
2488
2567
| invalid-unit-state( op-name, n, desc) with:
2489
2568
method render-fancy-reason( self, maybe-stack-loc, src-available, maybe-ast) :
0 commit comments