Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear error when module import name is same as variable name #7090

Closed
bluwy opened this issue Jan 2, 2022 · 0 comments · Fixed by #7145
Closed

Unclear error when module import name is same as variable name #7090

bluwy opened this issue Jan 2, 2022 · 0 comments · Fixed by #7145
Labels
bug compiler Changes relating to the compiler

Comments

@bluwy
Copy link
Member

bluwy commented Jan 2, 2022

Describe the bug

If I import a variable in context="module", and in the normal script tag declare the same variable name, e.g.

<script context="module">
	import { FOO } from "./test"
</script>

<script>
	let FOO
</script>

{FOO}

Compiler with fail with Cannot read properties of undefined (reading 'index') in Node and Chrome. undefined is not an object (evaluating 'member.index') in Safari.

Having the import in the normal script tag errors too, but is perfectly valid, with the message of Identifier 'FOO' has already been declared, which is clear of what the error is. I think we should have the same error message when the import is in context="module"

Originally reported at sveltejs/vite-plugin-svelte#243

Reproduction

https://svelte.dev/repl/cd32e723442a46a581de4d2efadc4037?version=3.44.3

Logs

Cannot read properties of undefined (reading 'index')

System Info

System:
    OS: macOS 12.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 126.38 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    npm: 8.3.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
    Watchman: 2021.12.27.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 96.0.4664.110
    Firefox: 94.0.2
    Safari: 15.2

Severity

annoyance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug compiler Changes relating to the compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant