What do I wrong with Sassc (2.4.0) or is it just a bug, that any call to color.new(...) leads to an error?

78 views Asked by At

For the impatient: fast to reproduce:

begin
    color=SassC::Script::Value::Color.new()
rescue Exception => e
    puts e
end

---------> Unable to determine color configuration¹

begin
    color=SassC::Script::Value::Color.new(1,2,3)
rescue Exception => e
    puts e
end

---------> wrong number of arguments (given 3, expected 0)

¹ this error fits to the original gem source:

  # Creates a new color with (`red`, `green`, `blue`) or (`hue`, `saturation`, `lightness`
  # values, plus an optional `alpha` transparency value.
  def initialize(red:nil, green:nil, blue:nil, hue:nil, saturation:nil, lightness:nil, alpha:1.0)
    if red && green && blue && alpha
      @mode = :rgba
      @red = SassC::Util.clamp(red.to_i, 0, 255)
      @green = SassC::Util.clamp(green.to_i, 0, 255)
      @blue = SassC::Util.clamp(blue.to_i, 0, 255)
      @alpha = SassC::Util.clamp(alpha.to_f, 0.0, 1.0)
    elsif hue && saturation && lightness && alpha
      @mode = :hsla
      @hue = SassC::Util.clamp(hue.to_i, 0, 360)
      @saturation = SassC::Util.clamp(saturation.to_i, 0, 100)
      @lightness = SassC::Util.clamp(lightness.to_i, 0, 100)
      @alpha = SassC::Util.clamp(alpha.to_f, 0.0, 1.0)
    else
      raise SassC::UnsupportedValue, "Unable to determine color configuration for"
    end
  end

versions:

  • Rails 7.0.4.2

  • ruby 2.7.7p221

  • sassc (2.4.0)

The more detailed explain:

I am migrating from Sass to SassC. I am using a hand full external function extensions wit Sass.

I soon got the error to_s() wrong number of arguments (given 1, expected 0)

I started monkey patching SassC for a workaround, but always ended up in errors like wrong number of arguments (given n, expected 0)

After almost the half of function patched I give up, because that's not the idea of a (monkey) patch.

Conclusion:

I (almost) got my functions running, but after replacing about 10 original ones from SassC - mostly replacing to_s(opts) with just to_s, I think, that there is something wrong.

My fault, or a SassC bug?

0

There are 0 answers