libsass icon indicating copy to clipboard operation
libsass copied to clipboard

map-remove() should reject a combination of positional and named keys

Open nex3 opened this issue 5 years ago • 2 comments

In LibSass, map-remove((c: d, e: f), c, $key: e) currently returns the empty map. It should fail, since the $key parameter is being passed by both position and name.

nex3 avatar Jun 28 '19 00:06 nex3

Hi!

I'm trying to fullfill this spec (https://github.com/sass/sass-spec/blob/master/spec/core_functions/map/remove.hrx#L155) in https://github.com/scssphp/scssphp/ but as map-remove signature is map-remove($map, $key...)

this spec is in conflict with

https://github.com/sass/sass-spec/blob/master/spec/non_conformant/scss-tests/091_test_function_var_and_splat_args_pass_through_keywords.hrx and https://github.com/sass/sass-spec/blob/master/spec/non_conformant/scss-tests/072_test_mixin_var_and_splat_args_pass_through_keywords.hrx

that are in both case passing a positionnal argument #1 and a named argument $a

I have the feeling that fullfilling all 3 specs needs to accept named and positionnal if only one argument in the function definition, which seems a bit inconsistant

Cerdic avatar Aug 21 '20 08:08 Cerdic

@Cerdic the trick is that the implementation actually achieves that through an overloaded function rather than single signature: https://github.com/sass/dart-sass/blob/3d39f22cbff8097c212dd90a507c22dd808c3f19/lib/src/functions/map.dart#L110-L118

So this is indeed something that cannot be achieved for userland functions (which cannot have overloads)

stof avatar Mar 14 '21 11:03 stof