Description
Some items are seen as type variable
when they are not, depending on some weird combination of indentation, extension, ...
For example, the folliwing:
foo :: Int
-> Int
foo l = 10
Gives me the following tree (observed in neovim using InspectTree
:
(signature) ; [8:1 - 9:9]
name: (variable) ; [8:1 - 3]
type: (fun) ; [8:8 - 9:9]
(type_name) ; [8:8 - 10]
(type) ; [8:8 - 10]
(type_name) ; [9:7 - 9]
(type) ; [9:7 - 9]
(function) ; [10:1 - 10]
name: (variable) ; [10:1 - 3]
patterns: (patterns) ; [10:5 - 5]
(pat_name) ; [10:5 - 5]
(variable) ; [10:5 - 5]
rhs: (exp_literal) ; [10:9 - 10]
(integer) ; [10:9 - 10]
However, the following:
foo :: Int
-> Int
foo l = 10
(see the subtle difference in indentation of the -> Int
gives me:
(function) ; [1:1 - 3:10]
pattern: (pat_typed) ; [1:1 - 3:5]
pattern: (pat_name) ; [1:1 - 3]
(variable) ; [1:1 - 3]
type: (fun) ; [1:8 - 3:5]
(type_name) ; [1:8 - 10]
(type) ; [1:8 - 10]
(type_apply) ; [2:6 - 3:5]
(type_name) ; [2:6 - 8]
(type) ; [2:6 - 8]
(type_name) ; [3:1 - 3]
(type_variable) ; [3:1 - 3]
(type_name) ; [3:5 - 5]
(type_variable) ; [3:5 - 5]
rhs: (exp_literal) ; [3:9 - 10]
(integer) ; [3:9 - 10]
See how most identifiers are considered as type_variable
now.
I also observed similar issue (i.e. some part of the code turned to type_variable
) on different configuration, but that's difficult to extract.
For example, this piece of code:
-- |
-- Solve a model for (a subset of) the given time steps.
--
-- The solving ends either when we reach the end of the given time steps, or
-- when the solving triggers an event that stops the ODE solver.
solveBetweenTwoEvents
:: forall m . (Katip m)
=> OdeLlvmCaches
-> InlinedModel DiffModel
-> SolverOpts
-> ModelOverlay -- ^ Initial transformation to apply to the model
-> [NDouble] -- ^ Time steps to solve for
-> m SolverResult
solveBetweenTwoEvents caches mdl solver_opts overlay desired_timesteps = do
let
localModel = updateMdlInitCond mdl (overlayInitialConditions overlay)
allow_events_at_t0 = overlayIsFirstChunk overlay
localRawResults0 :: SolverResult <- integrateModel caches localModel allow_events_at_t0 solver_opts (VS.fromList desired_timesteps)
return $ if
-- leave the very first chunk as is
| overlayIsFirstChunk overlay -> localRawResults0
-- when solving is stopped by an event, keep the first row in case it is
-- the only row, see https://git.novadiscovery.net/jinko/jinko/-/merge_requests/3609
| solverStop localRawResults0 -> localRawResults0
-- if the chunk is not the very first chunk, we remove the first row of the
-- result because it is a duplicate of the last row of the previous result.
| Varying ts <- resVals (solverTimes localRawResults0), VS.length ts > 1 -> dropFirstTime localRawResults0
| otherwise -> error "The impossible happened, SolverResult only has zero or one time step" -- should not happen
Remove the $
after the return
, and suddently, a lot of the code (and other functions) are turned to type variables (orange colouring here):
I'm unsure which additional information I can provide. This is my neovim version:
NVIM v0.10.0-dev-1094d0c
Build type: Release
LuaJIT 2.1.0-beta3
Here is the feedback of my neovim checkhealth, at least the part related to tree-sitter:
nvim-treesitter: require("nvim-treesitter.health").check()
Installation ~
- OK `tree-sitter` found 0.20.8 (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v18.17.1 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `gcc` executable found. Selected from { "gcc", "cc", "gcc", "clang", "cl", "zig" }
Version: gcc (GCC) 12.3.0
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.
OS Info:
{
machine = "x86_64",
release = "6.5.4",
sysname = "Linux",
version = "#1-NixOS SMP PREEMPT_DYNAMIC Tue Sep 19 10:30:30 UTC 2023"
} ~
Parser/Features H L F I J
- bash x ✓ ✓ . x
- c ✓ ✓ ✓ ✓ ✓
- haskell ✓ . ✓ . ✓
- javascript ✓ ✓ ✓ ✓ ✓
- lua ✓ ✓ ✓ ✓ ✓
- markdown ✓ . ✓ ✓ ✓
- markdown_inline ✓ . . . ✓
- pyf ✓ . . . ✓
- python ✓ ✓ ✓ ✓ ✓
- query ✓ ✓ ✓ ✓ ✓
- typescript ✓ ✓ ✓ ✓ ✓
- vim ✓ ✓ ✓ . ✓
- vimdoc ✓ . . . ✓
- vue ✓ . ✓ ✓ ✓
Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang} ~
The following errors have been detected: ~
- ERROR bash(highlights): ...-1094d0c/share/nvim/runtime/lua/vim/treesitter/query.lua:248: Query error at 37:3. Invalid node type "":
"<&-"
^
bash(highlights) is concatenated from the following files:
| [ERROR]:"/home/guillaume/.vim/plugged/nvim-treesitter/queries/bash/highlights.scm", failed to load: ...-1094d0c/share/nvim/runtime/lua/vim/treesitter/query.lua:248: Query error at 37:3. Invalid node type "":
"<&-"
^
- ERROR bash(injections): ...-1094d0c/share/nvim/runtime/lua/vim/treesitter/query.lua:248: Query error at 9:4. Invalid node type "heredoc_end":
(heredoc_end) @injection.language)
^
bash(injections) is concatenated from the following files:
| [ERROR]:"/home/guillaume/.vim/plugged/nvim-treesitter/queries/bash/injections.scm", failed to load: ...-1094d0c/share/nvim/runtime/lua/vim/treesitter/query.lua:248: Query error at 9:4. Invalid node type "heredoc_end":
(heredoc_end) @injection.language)
I actually don't know how to check which version of the haskell rules is packaged with this neovim version.