🏠 back to Observable

cell block local function reference code highlight bug:


#1

Minor bug: draw appears to be grayed out in this code line: .on(‘word’, draw);

see code behind cloud cell:


#2

Yep, unfortunately that one has an existing issue in CodeMirror and no clear strategy for a fix, because hoisting requires CodeMirror to color something differently based on code that comes after it.


#3

Workaround: don’t ever use the bare function foo(bar) {} syntax. Instead assign functions to variables like const foo = function foo(bar) {}.

Hoisting is a pain to reason about even for humans.


#4

@jrus well, that’s an easy fix. yeah, defining those functions outside of code block def. solves the issue.

I just sort of stumbled on it yesterday and thought it was odd for inner functions and closures :slight_smile:

@tom that CodeMirror issue link is 404, but thanks for looking into it and jotting a note