kotet/progress

Range violation in IncrementalBar

Closed this issue · 1 comments

When using

auto b = new IncrementalBar();
b.bar_prefix = " [";
b.bar_suffix = "] ";
b.width = 50;
b.max = 500;
foreach(i; 0 .. b.max)
{
  b.next();
}

exception appears:

[█████████████......................................] 129/500
core.exception.RangeError@../../.dub/packages/progress-3.0.0/progress/source/progress/bar.d(97): Range violation
----------------
??:? _d_arraybounds [0x4a4fdd]
??:? progress.bar.__array [0x49e659]
../../.dub/packages/progress-3.0.0/progress/source/progress/bar.d:97 void progress.bar.IncrementalBar.update() [0x49c3e5]
../../.dub/packages/progress-3.0.0/progress/source/progress/package.d:106 void progress.Infinite.next(ulong) [0x49d1aa]
progressbar.d:43 _Dmain [0x49ba72]
??:? _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv [0x4a818b]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x4a80b3]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0x4a8130]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x4a80b3]
??:? _d_run_main [0x4a801f]
??:? main [0x49c031]
??:? __libc_start_main [0xe71f482f]

Adding if (phase >= nphases) phase = nphases - 1; would fix that.

kotet commented

Thanks!