Something like this should be possible, and the
blocks/procedures,js and
core/procedures.js files are the place to start. Be aware that all variables in blockly, including the user-function arguments, are global variables. You'll want to look at how user-functions definitions interact with the workspace's
VariableMap. The
createVariable() method does allow you to attach an optional type string to the block, which may help you.
That said, that may force you to use typed variables everywhere, replacing use of
blocks/variables.js with
blocks/variables_dynamic.js. This is an in-development feature that requires a little extra work to support the toolbox. I suggest looking at the "Categories (type variables)" toolbox in the
playground. For those tests, each variable type has a separate "Create variable" button.
Looking at that, you may want to consider a function mutator toolbox with separate argument blocks for each allow variable type, instead of drop downs on each block. These might be color coded to match "Math" (number), "Logic" (boolean), "Text" (string) blocks.