observablehq / feedback

Customer submitted bugs and feature requests
42 stars 3 forks source link

Invalid viewof/mutable imports cause unprefixed variable to import instead #388

Closed mootari closed 2 years ago

mootari commented 2 years ago

Describe the bug

Any imported cell name can be prefixed with viewof or mutable without generating an error. The runtime will simply import the unprefixed cell.

To Reproduce

Run the following code:

// Note: "cars" exists, "viewof cars" does not.
import {viewof cars} from '@observablehq/demo'
cars

Expected behavior

  1. cars is greyed out and unlinked in the Inspector representation of the import cell.
  2. Referencing cars results in a RuntimeError.

Screenshot

image
mbostock commented 2 years ago

This is the expected behavior. When you import viewof cars, you are implicitly also importing cars, but there’s no requirement on how the two are related.