haskell / haskell/haskell-language-server

definition.Imported symbol (reexported) fails without `$TEMPDIR/hls-test-root`

Open
#4,348 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
3d 21h
Merged PRs (30d)
13

Description

running `HLS_TEST_HARNESS_NO_TESTDIR_CLEANUP=1 HLS_TEST_LOG_STDERR=1 TASTY_PATTERN="/definition.Imported symbol (reexported)/" cabal test ghcide-tests`
FAILS (>=GHC94)
```
expected: Location {_uri = Uri {getUri = "$TMPDIR/hls-test-root/extra-dir-85406152527/Bar.hs"}, _range = Range {_start = Position {_line = 3, _character = 5}, _end = Position {_line = 3, _character = 8}}}
but got: Location {_uri = Uri {getUri = "$TMPDIR/hls-test-root/extra-dir-85406152527/Bar.hs"}, _range = Range {_start = Position {_line = 3, _character = 0}, _end = Position {_line = 3, _character = 14}}}
```

### Notes
- AtPoint.hs.gotoDefinition calls locationsAtPoint
- it is using nameToLocation when failing
- `itExists <- liftIO $ doesFileExist fs` returns true
- doesn't seem to be falling back to db
- in `srcSpanToLocation sp`
`rng <- srcSpanToRange src`
reports a different location from what's expected in the test
- the `sp` comes from
`nameSrcSpan name`
in that branch.

_Originally posted by @komikat in https://github.com/haskell/haskell-language-server/issues/4273#issuecomment-2175957975_

Contributor guide

No contributing guide indexed for this repository

Research direction

Run the reported cabal test command with the HLS_TEST_HARNESS_NO_TESTDIR_CLEANUP and HLS_TEST_LOG_STDERR settings, then inspect AtPoint.hs.gotoDefinition and locationsAtPoint. Trace the nameToLocation path through srcSpanToLocation and compare nameSrcSpan with the expected range for definition.Imported symbol (reexported). Done means the test reports the expected location without requiring $TMPDIR/hls-test-root.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.