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

Functions incorrectly marked as unreferenced #108167

Closed
oliversalzburg opened this issue Oct 6, 2020 · 1 comment
Closed

Functions incorrectly marked as unreferenced #108167

oliversalzburg opened this issue Oct 6, 2020 · 1 comment
Assignees
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)

Comments

@oliversalzburg
Copy link

Issue Type: Bug

Given this code:

const fs = require("fs");

return foo()
  .then(bar);

function foo() {
  return new Promise((resolve) => {
    resolve();
  });
}

function bar() {
}

VS Code will mark the functions foo and bar as unused:

image

Making apparently random code changes can partially resolve the situation or make it worse again.

Commenting out the require statement will result in both functions being detected as being used. Reverting the change also marks the functions as unused again.

Sometimes only bar is considered unused.

VS Code version: Code 1.49.3 (2af0510, 2020-10-02T17:57:01.595Z)
OS version: Windows_NT x64 10.0.19041
Remote OS version: Linux x64 4.19.128-microsoft-standard
Remote OS version: Linux x64 4.19.128-microsoft-standard
Remote OS version: Linux x64 4.19.128-microsoft-standard
Remote OS version: Linux x64 4.19.128-microsoft-standard

System Info
Item Value
CPUs Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz (12 x 3598)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 63.91GB (42.09GB free)
Process Argv --folder-uri=vscode-remote://wsl+Ubuntu/home/oliver/fairmanager/fairmanager/static2 --remote=wsl+Ubuntu --crash-reporter-id f825acfe-92fa-4526-a38a-f8815cf9f7ea
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 4.19.128-microsoft-standard
CPUs Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz (12 x 3597)
Memory (System) 50.14GB (42.51GB free)
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 4.19.128-microsoft-standard
CPUs Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz (12 x 3597)
Memory (System) 50.14GB (42.51GB free)
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 4.19.128-microsoft-standard
CPUs Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz (12 x 3597)
Memory (System) 50.14GB (42.51GB free)
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 4.19.128-microsoft-standard
CPUs Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz (12 x 3597)
Memory (System) 50.14GB (42.51GB free)
VM 0%
Extensions (27)
Extension Author (truncated) Version
better-toml bun 0.3.2
vscode-eslint dba 2.1.8
javascript-ejs-support Dig 1.3.1
xml Dot 2.5.1
eslint-disable-snippets drK 1.2.0
gitlens eam 10.2.2
EditorConfig Edi 0.15.1
prettier-vscode esb 5.7.1
generateuuid Fir 0.0.5
shell-format fox 7.0.1
terraform has 2.2.3
vscode-drawio hed 1.0.0
vscode-esformatter how 1.6.0
output-colorizer IBM 0.1.2
code-beautifier mic 2.3.3
vscode-puglint mrm 2.3.0
vscode-docker ms- 1.6.0
remote-containers ms- 0.140.1
remote-ssh ms- 0.55.0
remote-ssh-edit ms- 0.55.0
remote-wsl ms- 0.44.5
vscode-remote-extensionpack ms- 0.20.0
vscode-paste-image mus 1.0.4
vscode-yaml red 0.11.1
lit-plugin run 1.2.1
language-pde Tob 1.4.6
vscode-icons vsc 11.0.0

(1 theme extensions excluded)

@mjbvz
Copy link
Contributor

mjbvz commented Oct 8, 2020

That code is not valid JS; you can't have a top level return statement in a file

To see this error, enable semantic checking

@mjbvz mjbvz closed this as completed Oct 8, 2020
@mjbvz mjbvz added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Oct 8, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
Development

No branches or pull requests

2 participants