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

nimsuggest: Crash when parsing const x = readFile(...) #24530

Open
foldl opened this issue Dec 12, 2024 · 1 comment
Open

nimsuggest: Crash when parsing const x = readFile(...) #24530

foldl opened this issue Dec 12, 2024 · 1 comment
Labels

Comments

@foldl
Copy link
Contributor

foldl commented Dec 12, 2024

Description

This file will crash nimsuggest:

proc bug(a: string): string =
  if a == "":
    const compiled_file = readFile("../scripts/models.json")
    return compiled_file
  else:
    return a

echo bug("aa")

Note that ../scripts/models.json is a valid file.

Log from langserver:

DBG ShowMessage                                message="Using Nim Compiler Version 2.2.0 [Windows: amd64]"
INF Starting nimsuggest                        root=".....\\bug.nim" timeout=120000 path="C:\\Programs\\nim-2.2.0\\bin\\nimsuggest.exe" workingDir="......"
DBG Parsing nimsuggest capability              capability=con
DBG Parsing nimsuggest capability              capability=exceptionInlayHints
DBG Parsing nimsuggest capability              capability=unknownFile
DBG Nimsuggest Capabilities                    capabilities="{con, exceptionInlayHints, unknownFile}"
ERR NimSuggest Error (stderr)                  err="syncio.nim(855)          readFile\nError: unhandled exception: cannot open: ../scripts/models.json [IOError]\n"
DBG NimSuggest needed to be restarted due to an error 
WRN Server stopped.                            projectFile="......bug.nim"
DBG ShowMessage                                message="Server failed with syncio.nim(855)          readFile\nError: unhandled exception: cannot open: ../scripts/models.json [IOError]\n."

Nim Version

Nim Compiler Version 2.2.0 [Windows: amd64]
Compiled at 2024-10-02
Copyright (c) 2006-2024 by Andreas Rumpf

active boot switches: -d:release

Current Output

Report error and exit:


Error: unhandled exception: cannot open: ../scripts/models.json [IOError]


### Expected Output

_No response_

### Known Workarounds

No. langserer will be unavailable for source files containing such statements.

### Additional Information

_No response_
@metagn metagn added Compiler Crash Nimsuggest VM see also `const` label labels Dec 13, 2024
@metagn
Copy link
Collaborator

metagn commented Dec 13, 2024

Note that ../scripts/models.json is a valid file.

This could be just a path resolution problem (maybe try a relative path to currentSourcePath()) but this is a separate issue, it still shouldn't crash the entire compiler

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

No branches or pull requests

2 participants