args icon indicating copy to clipboard operation
args copied to clipboard

addMultiOption mutable default leaks state

Open davidmorgan opened this issue 4 years ago • 1 comments

var parser = ArgParser()..addMultiOption('foo');
parser.parse([])['foo']).add('leaked state');
expect(parser.parse([])['foo'], isEmpty);

  Expected: empty
    Actual: ['leaked state']

We could either make the default const or make it always a new copy.

davidmorgan avatar Mar 19 '21 10:03 davidmorgan

My only concern is the potentially breaking nature of fixing this.... anything we do would technically be breaking although the copy approach would be very unlikely to break anybody I think.

jakemac53 avatar Mar 19 '21 14:03 jakemac53