@@ -2471,122 +2471,101 @@ data RuntimeError:
24712471 [ ED . error: base-err]
24722472 end
24732473 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" ) ]
24762483 [ ED . error:
2477- cases ( O . Option ) maybe-stack-loc( 0 , false ) :
2484+ cases ( O . Option ) maybe-stack-loc( 0 , true ) block :
24782485 | some( loc) =>
2486+ default-err-msg = [ ED . sequence:
2487+ ed-intro( self. reason, loc, -1 , true ) ,
2488+ ED . cmcode( loc) ,
2489+ base-err-msg]
24792490 if loc. is-builtin() :
24802491 [ 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,
24892494 please-report-bug() ]
24902495 else if src-available( loc) :
24912496 cases ( O . Option ) maybe-ast( loc) :
24922497 | 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
25202519 end
25212520 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
25322522 end
25332523 | none =>
25342524 [ ED . sequence:
25352525 [ ED . para:
25362526 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]
25462530 end ]
25472531 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" ) ]
25492539 [ ED . error: ED . maybe-stack-loc( 0 , false ,
25502540 lam ( loc) :
25512541 [ 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]
25602544 end ,
25612545 [ ED . sequence:
25622546 [ ED . para:
25632547 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] ) ]
25732551 end
2574- | invalid-unit-state( op-name, n, desc) with:
2552+ | invalid-unit-state( opname, n, desc) with:
2553+ # TODO: update
25752554 method render-fancy-reason( self, maybe-stack-loc, src-available, maybe-ast) :
25762555 [ ED . error:
25772556 cases ( O . Option ) maybe-stack-loc( 0 , false ) :
25782557 | some( loc) =>
25792558 if loc. is-builtin() :
25802559 [ ED . sequence:
2581- ed-intro( self. op-name + " function" , loc, -1 , true ) ,
2560+ ed-intro( self. opname + " function" , loc, -1 , true ) ,
25822561 [ ED . para:
25832562 ED . code( ED . text( tostring( self. n))) ,
25842563 ED . text( " is an invalid argument because: " ) ,
25852564 ED . text( self. desc) ] ,
25862565 please-report-bug() ]
25872566 else if src-available( loc) :
25882567 [ ED . sequence:
2589- ed-intro( self. op-name + " function" , loc, -1 , true ) ,
2568+ ed-intro( self. opname + " function" , loc, -1 , true ) ,
25902569 ED . cmcode( loc) ,
25912570 [ ED . para:
25922571 ED . code( ED . text( tostring( self. n))) ,
@@ -2596,7 +2575,7 @@ data RuntimeError:
25962575 | none =>
25972576 [ ED . sequence:
25982577 [ ED . para:
2599- ED . text( "The " + self. op-name + " function failed." ) ] ,
2578+ ED . text( "The " + self. opname + " function failed." ) ] ,
26002579 [ ED . para:
26012580 ED . code( ED . text( tostring( self. n))) ,
26022581 ED . text( " is an invalid argument because: " ) ,
@@ -2607,14 +2586,14 @@ data RuntimeError:
26072586 [ ED . error: ED . maybe-stack-loc( 0 , false ,
26082587 lam ( loc) :
26092588 [ ED . sequence:
2610- ed-simple-intro( self. op-name + " function" , loc) ,
2589+ ed-simple-intro( self. opname + " function" , loc) ,
26112590 [ ED . para:
26122591 ED . code( ED . text( tostring( self. n))) ,
26132592 ED . text( " is an invalid argument because: " ) ,
26142593 ED . text( self. desc) ]]
26152594 end ,
26162595 [ ED . sequence:
2617- [ ED . para: ED . text( "The " + self. op-name + " function failed." ) ] ,
2596+ [ ED . para: ED . text( "The " + self. opname + " function failed." ) ] ,
26182597 [ ED . para:
26192598 ED . code( ED . text( tostring( self. n))) ,
26202599 ED . text( " is an invalid argument because: " ) ,
0 commit comments