       when @chunk[...3] is '///'
         {tokens, index} = @matchWithInterpolations @chunk[3..], HEREGEX, '///', 3
       when match = REGEX.exec @chunk
-        [regex] = match
+        [regex, closed] = match
         index = regex.length
         prev = last @tokens
-        return 0 if prev and (prev[0] in (if prev.spaced then NOT_REGEX else NOT_SPACED_REGEX))
+        if prev
+          if prev.spaced and prev[0] in CALLABLE
+            return 0 if not closed or POSSIBLY_DIVISION.test regex
+          else if prev[0] in NOT_REGEX
+            return 0
+        @error 'missing / (unclosed regex)' unless closed
       else
         return 0
 


# Regex-matching-regexes.
REGEX = /// ^
  / (?! [\s=] ) (    # disallow leading whitespace or equals sign
  ?: [^ [ / \n \\ ]  # every other thing
   | \\.             # anything (but newlines) escaped
   | \[              # character class
       (?: \\. | [^ \] \n \\ ] )*
     ]
  )+ /
///

REGEX_FLAGS  = /^\w*/


REGEX_ILLEGAL = /// ^ ( / | /{3}\s*) (\*) ///

POSSIBLY_DIVISION   = /// ^ /=?\s ///

# Other regexes.
MULTILINER          = /\n/g

