Reply to thread

Heh, we have started discussing this code more generally in Slack just now and I just made basically the same point.


The true bug here is not actually the errors that might happen if someone passes in a non-string. The bug here is people passing non-strings to it at all.


Type safety as I am in favour of and Kirby is suggesting here would help developers identify such errors much sooner, ideally during development and before shipping.


It really would be just the add-ons that should fix this. Ultimately, for example, a developer is passing a value in here and is expecting something to happen. If they pass in the wrong thing and that results in some default behaviour that bug could be hidden as it stands, and if we exacerbate that further by casting random values to string, that further hides what could be a genuine mistake (such as typing a variable name wrong).


Points noted about how enforcing this can potentially break things, but often things like this should be fixed at source which unfortunately probably means we're going to enforce this more strictly and probably generate more errors, not fewer.


Back
Top Bottom