Transformc(...)[0] does not work in OSL

Hi.
I’m new to OSL.
I’m trying to make something that converts RGB to HSV and get something else out of it.
However I’m stuck right here:

shader my_osl_node(color some_color_input = 0......, output float out_float= 1.0)
{
....
    out_float = transformc("hsv", some_color_input)[0];
....
}

What I want here is to get Hue from RGB color.

  • To get specific H, S, or V (R, G, or B) channel from color, in OSL: color[int].
  • transformc returns color
  • So I’m expecting transformc(“hsv”, some_color_input)[0] to return Hue of some_color_input.

However this part of code makes syntax error. There is error message in blender console, but it does not specify what is wrong.

ERROR: C:\\Users\\_____\\AppData\\Local\\Temp\\tmp206n04zh.osl:4: error: Syntax error: syntax error
Error: OSL script compilation failed, see console for errors

This compiles

shader my_osl_node(color Color = 0.5, output vector out = (0))
{
    out = transformc("hsv", Color);
    
}

Or, here’s the code from T. Dinges which does work and provides H,S,V outputs.
https://raw.githubusercontent.com/sambler/osl-shaders/master/lib/TDSeparateHSV.osl