_hyperscript icon indicating copy to clipboard operation
_hyperscript copied to clipboard

Don't allow hyperscript zoo symbols to be overwritten

Open mattduffield opened this issue 3 years ago • 1 comments

When creating a hyperscript function, need to provide better compiler errors to let the developer know not to use zoo symbols.

When defining a function, I was using the variable my when I should have used elt or something like that.

The following function:

def toggleVisibilityBy(my, source, target, value) set selector to my.id.replace(source, target) if my.value == value add .hidden to #{selector}.closest("tr") else remove .hidden from #{selector}.closest("tr") end end Should really look like the following:

def toggleVisibilityBy(elt, source, target, value) set selector to elt.id.replace(source, target) if elt.value == value add .hidden to #{selector}.closest("tr") else remove .hidden from #{selector}.closest("tr") end end

Thanks!

mattduffield avatar Feb 23 '22 23:02 mattduffield

I agree there should be an error or warning when using reserved symbols as function arguments, and maybe other possibly conflicting contexts. I learned this the hard way after wasting about half an hour wondering why an argument kept being null, without realizing target is also a zoo symbol in def my_func(elt, target, args).

mamg22 avatar Jul 06 '23 00:07 mamg22