Warning 20: this argument will not be used by the function


#1

I have this hacked up ReasonML code embedding Javascript, and I can’t figure out what this error means:

Warning 20: this argument will not be used by the function.

Flymake is showing this warning for each occurrence of s4(). What am I doing wrong? What is the correct way to write this code?

      let s4 = [%raw
        {|
                 function a() {return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1)}
                 |}
      ];
      let toReturn =
        string_of_int(s4())
        ++ string_of_int(s4())
        ++ "-"
        ++ string_of_int(s4())
        ++ "-"
        ++ string_of_int(s4())
        ++ "-"
        ++ string_of_int(s4())
        ++ "-"
        ++ string_of_int(s4())
        ++ string_of_int(s4())
        ++ string_of_int(s4());
      toReturn;
    };

#2

Bucklescript doesn’t analyze Javascript code inside raw block. You must let it know what is it.

let s4: unit => int = [%raw
        {|
                 function a() {return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1)}
                 |}
      ];

#3

Thank you so much @thangngoc89! That solved my problem completely.


#4

You should check out @jaredly 's post about interoping with JS using raw statement here