Skip to content

Go to Definition for Complex Variable Assignment Jumps to Incorrect let Binding #2315

Description

@ParaN3xus

Is there an existing issue for this?

  • I have searched the existing issues

Platform

x64 Linux (linux-x64, Most Common)

Editor

VS Cod(e,ium)

Editor Version

Version: 1.107.0 (user setup)
Commit: 618725e67565b290ba4da6fe2d29f8fa1d4e3622
Date: 2025-12-10T07:43:47.883Z
Electron: 39.2.3
ElectronBuildId: 12895514
Chromium: 142.0.7444.175
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Windows_NT x64 10.0.26100

Describe the bug

The Go to Definition functionality in tinymist incorrectly resolves the definition location for variables assigned through complex functional expressions (involving closures). This was introduced by #1904.

Example:

#let currifyS(n, func) = {
  assert(type(n) == int and n >= 1)
  arg => if n == 1 {
    func(arg)
  } else {
    currifyS(n - 1, func.with(arg))
  }
}

#let currifyS0 = currifyS(2, currifyS)
#let flip(f) = (x, y) => f(y, x)


#let at_ = (x, y) => x.at(y)
#let at = currifyS0(2)(flip(at_))

#(/* position after */ at)

When invoking Go to Definition on the variable at, the feature jumps to the definition of a different function (currifyS) used in the assignment expression, instead of the variable's own let statement #let at = currifyS0(2)(flip(at_)).

Server Logs

[2025-12-15T16:18:47Z INFO  tinymist::cmd::lsp] tinymist version information: [["Build Timestamp", "2025-11-26T00:36:47.451149189Z"], ["Build Git Describe", "VERGEN_IDEMPOTENT_OUTPUT"], ["Commit SHA", "VERGEN_IDEMPOTENT_OUTPUT"], ["Commit Date", "None"], ["Commit Branch", "None"], ["Cargo Target Triple", "x86_64-unknown-linux-gnu"], ["Typst Version", "0.14.0"], ["Typst Source", "git+https://github.com/Myriad-Dreamin/typst.git?tag=tinymist/v0.14.0-rc1#4a3335c4a1ec26aa0cb3c747ae01ebc061c7832f"]]
[2025-12-15T16:18:47Z INFO  tinymist::cmd::lsp] starting language server: LspArgs { mirror: MirrorArgs { mirror: "", replay: "" }, font: CompileFontArgs { font_paths: [], ignore_system_fonts: false } }
[2025-12-15T16:18:47Z INFO  sync_ls::server] handling initialize - (0)
[2025-12-15T16:18:47Z INFO  tinymist::config] ServerState: config update_by_map {}
[2025-12-15T16:18:47Z INFO  tinymist::config] Server: running lsp in full mode
[2025-12-15T16:18:47Z INFO  tinymist::config] ServerState: config update_by_map {"colorTheme":"dark","compileStatus":"enable","completion":{"postfix":true,"postfixUfcs":true,"postfixUfcsLeft":true,"postfixUfcsRight":true,"symbol":"step","triggerOnSnippetPlaceholders":false},"configureDefaultWordSeparator":"disable","copyAndPaste":"enable","customizedShowDocument":true,"delegateFsRequests":false,"dragAndDrop":"enable","exportPdf":"never","exportTarget":"paged","formatterIndentSize":2,"formatterMode":"typstyle","formatterPrintWidth":120,"formatterProseWrap":false,"lint":{"enabled":false,"when":"onSave"},"onEnterEvent":true,"onPaste":"$root/$dir/assets","outputPath":"","preview":{"cursorIndicator":false,"fontPaths":[],"invertColors":"never","partialRendering":true,"pinPreviewFile":false,"refresh":"onType","scrollSync":"onSelectionChangeByMouse","sysInputs":{},"systemFonts":true},"previewFeature":"enable","probedServerPath":"/home/paran3xus/.vscode-server/extensions/myriad-dreamin.tinymist-0.14.4-linux-x64/out/tinymist","projectResolution":"singleFile","renderDocs":"enable","semanticTokens":"enable","showExportFileIn":null,"statusBarFormat":"{compileStatusIcon} {wordCount} [{fileName}]","supportExtendedCodeAction":true,"supportHtmlInMarkdown":true,"syntaxOnly":"auto","systemFonts":true,"trace":{"server":"off"},"triggerParameterHints":true,"triggerSuggest":true,"triggerSuggestAndParameterHints":true,"typingContinueCommentsOnNewline":true,"typstExtraArgs":[]}
[2025-12-15T16:18:47Z INFO  tinymist::server] ServerState: initialized with config Config { const_config: ConstConfig { position_encoding: Utf16, cfg_change_registration: true, notify_will_rename_files: true, tokens_dynamic_registration: true, tokens_overlapping_token_support: false, tokens_multiline_token_support: false, doc_line_folding_only: true, doc_fmt_dynamic_registration: true, locale: Some("en") }, const_dap_config: ConstDapConfig { path_format: Path, lines_start_at1: true, columns_start_at1: true }, delegate_fs_requests: false, customized_show_document: true, has_default_entry_path: false, notify_status: true, support_html_in_markdown: true, extended_code_action: true, development: false, syntax_only: false, color_theme: Some("dark"), entry_resolver: EntryResolver { project_resolution: SingleFile, root_path: None, roots: ["/home/paran3xus/projects/typst/playground"], entry: None, typst_toml_cache: {} }, lsp_inputs: {"x-preview": "{\"version\":1,\"theme\":\"dark\"}"}, periscope_args: None, typst_extra_args: Some(TypstExtraArgs { root_dir: None, entry: None, inputs: {}, font: CompileFontArgs { font_paths: [], ignore_system_fonts: false }, package: CompilePackageArgs { package_path: None, package_cache_path: None }, features: [], pdf_standard: [], ppi: 144.0, no_pdf_tags: false, creation_timestamp: None, cert: None }), semantic_tokens: Enable, completion: CompletionFeat { trigger_on_snippet_placeholders: false, trigger_suggest: true, trigger_parameter_hints: true, trigger_suggest_and_parameter_hints: true, symbol: Some(Step), postfix: Some(true), postfix_ufcs: Some(true), postfix_ufcs_left: Some(true), postfix_ufcs_right: Some(true), postfix_snippets: None }, preview: PreviewFeat { browsing: BrowsingPreviewOpts { args: None }, background: BackgroundPreviewOpts { enabled: false, args: None }, refresh: Some(OnType), partial_rendering: true, invert_colors: Enum(Never) }, lint: LintFeat { enabled: Some(false), when: Some(OnSave) }, on_enter: OnEnterFeat { handle_list: false }, font_opts: CompileFontArgs { font_paths: [], ignore_system_fonts: false }, font_paths: [], fonts: OnceLock(<uninit>), system_fonts: Some(true), watch_access_model: OnceLock(<uninit>), access_model: OnceLock(<uninit>), export_target: Paged, export_pdf: Never, output_path: PathPattern(""), formatter_mode: Typstyle, formatter_print_width: Some(120), formatter_indent_size: Some(2), formatter_prose_wrap: Some(false), warnings: [] }
[2025-12-15T16:18:47Z INFO  tinymist::config] creating AccessModel with delegation=false
[2025-12-15T16:18:47Z INFO  tinymist_project::watch] NotifyActor: start watching files...
[2025-12-15T16:18:47Z INFO  tinymist::project] ServerState: creating ProjectState, entry: EntryState { root: Some("/home/paran3xus/projects/typst/playground"), main: None }, inputs: {"x-preview": "{\"version\":1,\"theme\":\"dark\"}"}
[2025-12-15T16:18:47Z INFO  tinymist::config] creating SharedFontResolver with CompileFontArgs { font_paths: [], ignore_system_fonts: false }
[2025-12-15T16:18:47Z INFO  tinymist::tool::preview] Stopping all preview tasks
[2025-12-15T16:18:47Z INFO  tinymist::project] ServerState: creating ProjectState, entry: EntryState { root: Some("/home/paran3xus/projects/typst/playground"), main: None }, inputs: {"x-preview": "{\"version\":1,\"theme\":\"dark\"}"}
[2025-12-15T16:18:47Z INFO  sync_ls::server] handled  initialize - (0) in 231.15ms
[2025-12-15T16:18:47Z INFO  sync_ls::server] notifying initialized
[2025-12-15T16:18:47Z INFO  tinymist::lsp] server initialized
[2025-12-15T16:18:47Z INFO  sync_ls::server] notify initialized succeeded in 194.39µs
[2025-12-15T16:18:47Z INFO  sync_ls::server] handling workspace/executeCommand - (1)
[2025-12-15T16:18:47Z INFO  sync_ls::server] handling workspace/executeCommand - (2)
[2025-12-15T16:18:47Z INFO  sync_ls::server] handled  workspace/executeCommand - (1) in 1.14ms
[2025-12-15T16:18:47Z INFO  tinymist::cmd] first manual focusing is coming
[2025-12-15T16:18:47Z INFO  tinymist::input] the task of the primary is changing to TaskInputs { entry: Some(EntryState { root: Some("/home/paran3xus/projects/typst/playground"), main: Some(@ws/p0:0.0.0/test2.typ) }), inputs: None }
[2025-12-15T16:18:47Z INFO  tinymist::cmd] file focused: Some("/home/paran3xus/projects/typst/playground/test2.typ")
[2025-12-15T16:18:47Z INFO  sync_ls::server] notifying textDocument/didOpen
[2025-12-15T16:18:47Z INFO  tinymist::lsp] did open file:///home/paran3xus/.vscode-server/data/User/mcp.json
[2025-12-15T16:18:47Z INFO  sync_ls::server] handled  workspace/executeCommand - (2) in 311.42µs
[2025-12-15T16:18:47Z INFO  sync_ls::server] notify textDocument/didOpen succeeded in 36.00µs
[2025-12-15T16:18:47Z INFO  sync_ls::server] notifying textDocument/didClose
[2025-12-15T16:18:47Z INFO  sync_ls::server] notify textDocument/didClose succeeded in 31.89µs
[2025-12-15T16:18:47Z INFO  sync_ls::server] notifying textDocument/didOpen
[2025-12-15T16:18:47Z INFO  tinymist::lsp] did open file:///home/paran3xus/projects/typst/playground/test2.typ
[2025-12-15T16:18:47Z INFO  sync_ls::server] notify textDocument/didOpen succeeded in 34.44µs
[2025-12-15T16:18:47Z INFO  tinymist_project::compiler] /home/paran3xus/projects/typst/playground/test2.typ: compilation succeeded in 2.533018ms
[2025-12-15T16:18:47Z INFO  sync_ls::server] handling workspace/executeCommand - (3)
[2025-12-15T16:18:47Z INFO  sync_ls::server] handled  workspace/executeCommand - (3) in 52.18ms
[2025-12-15T16:18:47Z INFO  tinymist::project] Project: emit compilation again for ProjectInsId("primary"), reason: CompileSignal { by_mem_events: false, by_fs_events: true, by_entry_update: false }
[2025-12-15T16:18:47Z INFO  sync_ls::server] notifying $/setTrace
[2025-12-15T16:18:47Z WARN  sync_ls::server::lsp_srv] unhandled notification: $/setTrace
[2025-12-15T16:18:47Z INFO  sync_ls::server] notify $/setTrace succeeded in 10.92µs
[2025-12-15T16:18:47Z INFO  sync_ls::server] notifying workspace/didChangeConfiguration
[2025-12-15T16:18:48Z INFO  sync_ls::server] notify workspace/didChangeConfiguration succeeded in 150.25ms
[2025-12-15T16:18:48Z INFO  sync_ls::server] notifying $/setTrace
[2025-12-15T16:18:48Z WARN  sync_ls::server::lsp_srv] unhandled notification: $/setTrace
[2025-12-15T16:18:48Z INFO  sync_ls::server] notify $/setTrace succeeded in 7.82µs
[2025-12-15T16:18:48Z INFO  sync_ls::server] notifying workspace/didChangeConfiguration
[2025-12-15T16:18:48Z INFO  sync_ls::server] notify workspace/didChangeConfiguration succeeded in 33.66µs
[2025-12-15T16:18:48Z INFO  sync_ls::server] handling textDocument/documentColor - (4)
[2025-12-15T16:18:48Z INFO  sync_ls::server] handling textDocument/documentLink - (5)
[2025-12-15T16:18:48Z INFO  sync_ls::server] notifying textDocument/didOpen
[2025-12-15T16:18:48Z INFO  tinymist::lsp] did open file:///home/paran3xus/.vscode-server/data/User/mcp.json
[2025-12-15T16:18:48Z INFO  sync_ls::server] handled  textDocument/documentColor - (4) in 169.28µs
[2025-12-15T16:18:48Z INFO  sync_ls::server] notify textDocument/didOpen succeeded in 29.89µs
[2025-12-15T16:18:48Z INFO  sync_ls::server] notifying textDocument/didClose
[2025-12-15T16:18:48Z INFO  sync_ls::server] notify textDocument/didClose succeeded in 20.68µs
[2025-12-15T16:18:48Z INFO  sync_ls::server] handled  textDocument/documentLink - (5) in 135.22µs
[2025-12-15T16:18:48Z INFO  sync_ls::server] handling textDocument/codeAction - (6)
[2025-12-15T16:18:48Z INFO  sync_ls::server] handled  textDocument/codeAction - (6) in 159.52µs
[2025-12-15T16:18:48Z INFO  tinymist::project] Project: skip compilation for ProjectInsId("primary") due to harmless vfs changes
[2025-12-15T16:18:48Z INFO  tinymist::config] ServerState: config update_by_map {"colorTheme":"dark","compileStatus":"enable","completion":{"postfix":true,"postfixUfcs":true,"postfixUfcsLeft":true,"postfixUfcsRight":true,"symbol":"step","triggerOnSnippetPlaceholders":false},"development":null,"exportPdf":"never","exportTarget":"paged","fontPaths":null,"formatterIndentSize":2,"formatterMode":"typstyle","formatterPrintWidth":120,"formatterProseWrap":false,"hoverPeriscope":null,"lint":{"enabled":false,"when":"onSave"},"onEnter":null,"outputPath":"","preview":{"cursorIndicator":false,"fontPaths":[],"invertColors":"never","partialRendering":true,"pinPreviewFile":false,"refresh":"onType","scrollSync":"onSelectionChangeByMouse","sysInputs":{},"systemFonts":true},"projectResolution":"singleFile","rootPath":null,"semanticTokens":"enable","syntaxOnly":"auto","systemFonts":true,"tinymist":{"compileStatus":"enable","completion":{"postfix":true,"postfixUfcs":true,"postfixUfcsLeft":true,"postfixUfcsRight":true,"symbol":"step","triggerOnSnippetPlaceholders":false},"configureDefaultWordSeparator":"disable","copyAndPaste":"enable","dragAndDrop":"enable","exportPdf":"never","exportTarget":"paged","fontPaths":null,"formatterIndentSize":2,"formatterMode":"typstyle","formatterPrintWidth":120,"formatterProseWrap":false,"lint":{"enabled":false,"when":"onSave"},"onEnterEvent":true,"onPaste":"$root/$dir/assets","outputPath":"","preview":{"cursorIndicator":false,"fontPaths":[],"invertColors":"never","partialRendering":true,"pinPreviewFile":false,"refresh":"onType","scrollSync":"onSelectionChangeByMouse","sysInputs":{},"systemFonts":true},"previewFeature":"enable","projectResolution":"singleFile","renderDocs":"enable","rootPath":null,"semanticTokens":"enable","serverPath":null,"showExportFileIn":null,"statusBarFormat":"{compileStatusIcon} {wordCount} [{fileName}]","syntaxOnly":"auto","systemFonts":true,"trace":{"server":"off"},"typingContinueCommentsOnNewline":true,"typstExtraArgs":[]},"typstExtraArgs":[]}
[2025-12-15T16:18:48Z INFO  tinymist::config] Server: running lsp in full mode
[2025-12-15T16:18:48Z INFO  tinymist::lsp] new settings applied
[2025-12-15T16:18:48Z INFO  tinymist::config] ServerState: config update_by_map {"colorTheme":"dark","compileStatus":"enable","completion":{"postfix":true,"postfixUfcs":true,"postfixUfcsLeft":true,"postfixUfcsRight":true,"symbol":"step","triggerOnSnippetPlaceholders":false},"development":null,"exportPdf":"never","exportTarget":"paged","fontPaths":null,"formatterIndentSize":2,"formatterMode":"typstyle","formatterPrintWidth":120,"formatterProseWrap":false,"hoverPeriscope":null,"lint":{"enabled":false,"when":"onSave"},"onEnter":null,"outputPath":"","preview":{"cursorIndicator":false,"fontPaths":[],"invertColors":"never","partialRendering":true,"pinPreviewFile":false,"refresh":"onType","scrollSync":"onSelectionChangeByMouse","sysInputs":{},"systemFonts":true},"projectResolution":"singleFile","rootPath":null,"semanticTokens":"enable","syntaxOnly":"auto","systemFonts":true,"tinymist":{"compileStatus":"enable","completion":{"postfix":true,"postfixUfcs":true,"postfixUfcsLeft":true,"postfixUfcsRight":true,"symbol":"step","triggerOnSnippetPlaceholders":false},"configureDefaultWordSeparator":"disable","copyAndPaste":"enable","dragAndDrop":"enable","exportPdf":"never","exportTarget":"paged","fontPaths":null,"formatterIndentSize":2,"formatterMode":"typstyle","formatterPrintWidth":120,"formatterProseWrap":false,"lint":{"enabled":false,"when":"onSave"},"onEnterEvent":true,"onPaste":"$root/$dir/assets","outputPath":"","preview":{"cursorIndicator":false,"fontPaths":[],"invertColors":"never","partialRendering":true,"pinPreviewFile":false,"refresh":"onType","scrollSync":"onSelectionChangeByMouse","sysInputs":{},"systemFonts":true},"previewFeature":"enable","projectResolution":"singleFile","renderDocs":"enable","rootPath":null,"semanticTokens":"enable","serverPath":null,"showExportFileIn":null,"statusBarFormat":"{compileStatusIcon} {wordCount} [{fileName}]","syntaxOnly":"auto","systemFonts":true,"trace":{"server":"off"},"typingContinueCommentsOnNewline":true,"typstExtraArgs":[]},"typstExtraArgs":[]}
[2025-12-15T16:18:48Z INFO  tinymist::config] Server: running lsp in full mode
[2025-12-15T16:18:48Z INFO  tinymist::lsp] new settings applied
[2025-12-15T16:18:48Z INFO  sync_ls::server] handling textDocument/foldingRange - (7)
[2025-12-15T16:18:48Z INFO  sync_ls::server] handled  textDocument/foldingRange - (7) in 233.99µs
[2025-12-15T16:18:48Z INFO  sync_ls::server] handling textDocument/documentSymbol - (8)
[2025-12-15T16:18:48Z INFO  sync_ls::server] handled  textDocument/documentSymbol - (8) in 163.48µs
[2025-12-15T16:18:48Z INFO  sync_ls::server] notifying $/setTrace
[2025-12-15T16:18:48Z WARN  sync_ls::server::lsp_srv] unhandled notification: $/setTrace
[2025-12-15T16:18:48Z INFO  sync_ls::server] notify $/setTrace succeeded in 16.02µs
[2025-12-15T16:18:48Z INFO  sync_ls::server] handling textDocument/documentLink - (9)
[2025-12-15T16:18:48Z INFO  sync_ls::server] handled  textDocument/documentLink - (9) in 177.81µs
[2025-12-15T16:18:48Z INFO  sync_ls::server] handling textDocument/documentSymbol - (10)
[2025-12-15T16:18:48Z INFO  sync_ls::server] handled  textDocument/documentSymbol - (10) in 145.96µs
[2025-12-15T16:18:48Z INFO  sync_ls::server] notifying workspace/didChangeConfiguration
[2025-12-15T16:18:48Z INFO  sync_ls::server] notify workspace/didChangeConfiguration succeeded in 43.02µs
[2025-12-15T16:18:48Z INFO  sync_ls::server] handling textDocument/codeAction - (11)
[2025-12-15T16:18:48Z INFO  sync_ls::server] handled  textDocument/codeAction - (11) in 140.77µs
[2025-12-15T16:18:49Z INFO  sync_ls::server] notifying $/setTrace
[2025-12-15T16:18:49Z WARN  sync_ls::server::lsp_srv] unhandled notification: $/setTrace
[2025-12-15T16:18:49Z INFO  sync_ls::server] notify $/setTrace succeeded in 21.55µs
[2025-12-15T16:18:49Z INFO  sync_ls::server] handling textDocument/semanticTokens/full - (12)
[2025-12-15T16:18:49Z INFO  sync_ls::server] handling textDocument/codeLens - (13)
[2025-12-15T16:18:49Z INFO  sync_ls::server] notifying workspace/didChangeConfiguration
[2025-12-15T16:18:49Z INFO  sync_ls::server] notify workspace/didChangeConfiguration succeeded in 41.65µs
[2025-12-15T16:18:49Z INFO  sync_ls::server] handled  textDocument/codeLens - (13) in 83.65µs
[2025-12-15T16:18:49Z INFO  sync_ls::server] handled  textDocument/semanticTokens/full - (12) in 357.37µs
[2025-12-15T16:18:49Z INFO  sync_ls::server] notifying $/cancelRequest
[2025-12-15T16:18:49Z WARN  sync_ls::server::lsp_srv] unhandled notification: $/cancelRequest
[2025-12-15T16:18:49Z INFO  sync_ls::server] notify $/cancelRequest succeeded in 20.48µs
[2025-12-15T16:18:49Z INFO  tinymist::config] ServerState: config update_by_map {"colorTheme":"dark","compileStatus":"enable","completion":{"postfix":true,"postfixUfcs":true,"postfixUfcsLeft":true,"postfixUfcsRight":true,"symbol":"step","triggerOnSnippetPlaceholders":false},"development":null,"exportPdf":"never","exportTarget":"paged","fontPaths":null,"formatterIndentSize":2,"formatterMode":"typstyle","formatterPrintWidth":120,"formatterProseWrap":false,"hoverPeriscope":null,"lint":{"enabled":false,"when":"onSave"},"onEnter":null,"outputPath":"","preview":{"cursorIndicator":false,"fontPaths":[],"invertColors":"never","partialRendering":true,"pinPreviewFile":false,"refresh":"onType","scrollSync":"onSelectionChangeByMouse","sysInputs":{},"systemFonts":true},"projectResolution":"singleFile","rootPath":null,"semanticTokens":"enable","syntaxOnly":"auto","systemFonts":true,"tinymist":{"compileStatus":"enable","completion":{"postfix":true,"postfixUfcs":true,"postfixUfcsLeft":true,"postfixUfcsRight":true,"symbol":"step","triggerOnSnippetPlaceholders":false},"configureDefaultWordSeparator":"disable","copyAndPaste":"enable","dragAndDrop":"enable","exportPdf":"never","exportTarget":"paged","fontPaths":null,"formatterIndentSize":2,"formatterMode":"typstyle","formatterPrintWidth":120,"formatterProseWrap":false,"lint":{"enabled":false,"when":"onSave"},"onEnterEvent":true,"onPaste":"$root/$dir/assets","outputPath":"","preview":{"cursorIndicator":false,"fontPaths":[],"invertColors":"never","partialRendering":true,"pinPreviewFile":false,"refresh":"onType","scrollSync":"onSelectionChangeByMouse","sysInputs":{},"systemFonts":true},"previewFeature":"enable","projectResolution":"singleFile","renderDocs":"enable","rootPath":null,"semanticTokens":"enable","serverPath":null,"showExportFileIn":null,"statusBarFormat":"{compileStatusIcon} {wordCount} [{fileName}]","syntaxOnly":"auto","systemFonts":true,"trace":{"server":"off"},"typingContinueCommentsOnNewline":true,"typstExtraArgs":[]},"typstExtraArgs":[]}
[2025-12-15T16:18:49Z INFO  tinymist::config] Server: running lsp in full mode
[2025-12-15T16:18:49Z INFO  tinymist::lsp] new settings applied
[2025-12-15T16:18:49Z INFO  tinymist::config] ServerState: config update_by_map {"colorTheme":"dark","compileStatus":"enable","completion":{"postfix":true,"postfixUfcs":true,"postfixUfcsLeft":true,"postfixUfcsRight":true,"symbol":"step","triggerOnSnippetPlaceholders":false},"development":null,"exportPdf":"never","exportTarget":"paged","fontPaths":null,"formatterIndentSize":2,"formatterMode":"typstyle","formatterPrintWidth":120,"formatterProseWrap":false,"hoverPeriscope":null,"lint":{"enabled":false,"when":"onSave"},"onEnter":null,"outputPath":"","preview":{"cursorIndicator":false,"fontPaths":[],"invertColors":"never","partialRendering":true,"pinPreviewFile":false,"refresh":"onType","scrollSync":"onSelectionChangeByMouse","sysInputs":{},"systemFonts":true},"projectResolution":"singleFile","rootPath":null,"semanticTokens":"enable","syntaxOnly":"auto","systemFonts":true,"tinymist":{"compileStatus":"enable","completion":{"postfix":true,"postfixUfcs":true,"postfixUfcsLeft":true,"postfixUfcsRight":true,"symbol":"step","triggerOnSnippetPlaceholders":false},"configureDefaultWordSeparator":"disable","copyAndPaste":"enable","dragAndDrop":"enable","exportPdf":"never","exportTarget":"paged","fontPaths":null,"formatterIndentSize":2,"formatterMode":"typstyle","formatterPrintWidth":120,"formatterProseWrap":false,"lint":{"enabled":false,"when":"onSave"},"onEnterEvent":true,"onPaste":"$root/$dir/assets","outputPath":"","preview":{"cursorIndicator":false,"fontPaths":[],"invertColors":"never","partialRendering":true,"pinPreviewFile":false,"refresh":"onType","scrollSync":"onSelectionChangeByMouse","sysInputs":{},"systemFonts":true},"previewFeature":"enable","projectResolution":"singleFile","renderDocs":"enable","rootPath":null,"semanticTokens":"enable","serverPath":null,"showExportFileIn":null,"statusBarFormat":"{compileStatusIcon} {wordCount} [{fileName}]","syntaxOnly":"auto","systemFonts":true,"trace":{"server":"off"},"typingContinueCommentsOnNewline":true,"typstExtraArgs":[]},"typstExtraArgs":[]}
[2025-12-15T16:18:49Z INFO  tinymist::config] Server: running lsp in full mode
[2025-12-15T16:18:49Z INFO  tinymist::lsp] new settings applied
[2025-12-15T16:18:49Z INFO  sync_ls::server] handling workspace/executeCommand - (14)
[2025-12-15T16:18:49Z INFO  tinymist::input] the task of the primary is changing to TaskInputs { entry: Some(EntryState { root: Some("/home/paran3xus/projects/typst/playground"), main: None }), inputs: None }
[2025-12-15T16:18:49Z INFO  tinymist_project::compiler] ProjectCompiler: removing diag
[2025-12-15T16:18:49Z INFO  tinymist::cmd] file focused: None
[2025-12-15T16:18:49Z INFO  sync_ls::server] handled  workspace/executeCommand - (14) in 98.07µs
[2025-12-15T16:18:49Z INFO  sync_ls::server] notifying textDocument/didOpen
[2025-12-15T16:18:49Z INFO  tinymist::lsp] did open file:///home/paran3xus/.vscode-server/data/User/mcp.json
[2025-12-15T16:18:49Z INFO  sync_ls::server] notify textDocument/didOpen succeeded in 127.03µs
[2025-12-15T16:18:49Z INFO  sync_ls::server] notifying textDocument/didClose
[2025-12-15T16:18:49Z INFO  sync_ls::server] notify textDocument/didClose succeeded in 58.27µs
[2025-12-15T16:18:49Z INFO  sync_ls::server] notifying $/setTrace
[2025-12-15T16:18:49Z WARN  sync_ls::server::lsp_srv] unhandled notification: $/setTrace
[2025-12-15T16:18:49Z INFO  sync_ls::server] notify $/setTrace succeeded in 17.79µs
[2025-12-15T16:18:49Z INFO  sync_ls::server] notifying workspace/didChangeConfiguration
[2025-12-15T16:18:49Z INFO  sync_ls::server] notify workspace/didChangeConfiguration succeeded in 40.06µs
[2025-12-15T16:18:49Z INFO  tinymist::config] ServerState: config update_by_map {"colorTheme":"dark","compileStatus":"enable","completion":{"postfix":true,"postfixUfcs":true,"postfixUfcsLeft":true,"postfixUfcsRight":true,"symbol":"step","triggerOnSnippetPlaceholders":false},"development":null,"exportPdf":"never","exportTarget":"paged","fontPaths":null,"formatterIndentSize":2,"formatterMode":"typstyle","formatterPrintWidth":120,"formatterProseWrap":false,"hoverPeriscope":null,"lint":{"enabled":false,"when":"onSave"},"onEnter":null,"outputPath":"","preview":{"cursorIndicator":false,"fontPaths":[],"invertColors":"never","partialRendering":true,"pinPreviewFile":false,"refresh":"onType","scrollSync":"onSelectionChangeByMouse","sysInputs":{},"systemFonts":true},"projectResolution":"singleFile","rootPath":null,"semanticTokens":"enable","syntaxOnly":"auto","systemFonts":true,"tinymist":{"compileStatus":"enable","completion":{"postfix":true,"postfixUfcs":true,"postfixUfcsLeft":true,"postfixUfcsRight":true,"symbol":"step","triggerOnSnippetPlaceholders":false},"configureDefaultWordSeparator":"disable","copyAndPaste":"enable","dragAndDrop":"enable","exportPdf":"never","exportTarget":"paged","fontPaths":null,"formatterIndentSize":2,"formatterMode":"typstyle","formatterPrintWidth":120,"formatterProseWrap":false,"lint":{"enabled":false,"when":"onSave"},"onEnterEvent":true,"onPaste":"$root/$dir/assets","outputPath":"","preview":{"cursorIndicator":false,"fontPaths":[],"invertColors":"never","partialRendering":true,"pinPreviewFile":false,"refresh":"onType","scrollSync":"onSelectionChangeByMouse","sysInputs":{},"systemFonts":true},"previewFeature":"enable","projectResolution":"singleFile","renderDocs":"enable","rootPath":null,"semanticTokens":"enable","serverPath":null,"showExportFileIn":null,"statusBarFormat":"{compileStatusIcon} {wordCount} [{fileName}]","syntaxOnly":"auto","systemFonts":true,"trace":{"server":"off"},"typingContinueCommentsOnNewline":true,"typstExtraArgs":[]},"typstExtraArgs":[]}
[2025-12-15T16:18:49Z INFO  tinymist::config] Server: running lsp in full mode
[2025-12-15T16:18:49Z INFO  tinymist::lsp] new settings applied
[2025-12-15T16:18:49Z INFO  sync_ls::server] handling textDocument/codeAction - (15)
[2025-12-15T16:18:49Z INFO  sync_ls::server] handled  textDocument/codeAction - (15) in 271.09µs
[2025-12-15T16:18:49Z INFO  sync_ls::server] handling textDocument/codeLens - (16)
[2025-12-15T16:18:49Z INFO  sync_ls::server] handled  textDocument/codeLens - (16) in 200.08µs
[2025-12-15T16:18:49Z INFO  sync_ls::server] handling workspace/executeCommand - (17)
[2025-12-15T16:18:49Z INFO  tinymist::input] the task of the primary is changing to TaskInputs { entry: Some(EntryState { root: Some("/home/paran3xus/projects/typst/playground"), main: Some(@ws/p0:0.0.0/test2.typ) }), inputs: None }
[2025-12-15T16:18:49Z INFO  tinymist::cmd] file focused: Some("/home/paran3xus/projects/typst/playground/test2.typ")
[2025-12-15T16:18:49Z INFO  sync_ls::server] handled  workspace/executeCommand - (17) in 144.87µs
[2025-12-15T16:18:49Z INFO  tinymist_project::compiler] /home/paran3xus/projects/typst/playground/test2.typ: compilation succeeded in 166.496µs
[2025-12-15T16:18:50Z INFO  sync_ls::server] handling textDocument/codeAction - (18)
[2025-12-15T16:18:50Z INFO  sync_ls::server] handled  textDocument/codeAction - (18) in 216.84µs
[2025-12-15T16:18:50Z INFO  sync_ls::server] handling textDocument/semanticTokens/full/delta - (19)
[2025-12-15T16:18:50Z INFO  sync_ls::server] handled  textDocument/semanticTokens/full/delta - (19) in 280.02µs
[2025-12-15T16:18:52Z INFO  sync_ls::server] handling textDocument/definition - (20)
[2025-12-15T16:18:52Z INFO  sync_ls::server] handled  textDocument/definition - (20) in 591.09µs
[2025-12-15T16:18:52Z INFO  sync_ls::server] handling textDocument/hover - (21)
[2025-12-15T16:18:52Z INFO  sync_ls::server] handled  textDocument/hover - (21) in 264.87µs
[2025-12-15T16:18:52Z INFO  sync_ls::server] handling textDocument/documentHighlight - (22)
[2025-12-15T16:18:52Z INFO  sync_ls::server] handled  textDocument/documentHighlight - (22) in 173.38µs
[2025-12-15T16:18:52Z INFO  sync_ls::server] handling textDocument/definition - (23)
[2025-12-15T16:18:52Z INFO  sync_ls::server] handled  textDocument/definition - (23) in 262.85µs
[2025-12-15T16:18:52Z INFO  sync_ls::server] handling textDocument/codeLens - (24)
[2025-12-15T16:18:52Z INFO  sync_ls::server] handled  textDocument/codeLens - (24) in 174.01µs
[2025-12-15T16:18:53Z INFO  sync_ls::server] handling textDocument/codeAction - (25)
[2025-12-15T16:18:53Z INFO  sync_ls::server] handled  textDocument/codeAction - (25) in 183.23µs
[2025-12-15T16:18:54Z INFO  sync_ls::server] handling workspace/executeCommand - (26)
[2025-12-15T16:18:54Z INFO  tinymist::input] the task of the primary is changing to TaskInputs { entry: Some(EntryState { root: Some("/home/paran3xus/projects/typst/playground"), main: None }), inputs: None }
[2025-12-15T16:18:54Z INFO  tinymist_project::compiler] ProjectCompiler: removing diag
[2025-12-15T16:18:54Z INFO  tinymist::cmd] file focused: None
[2025-12-15T16:18:54Z INFO  sync_ls::server] handled  workspace/executeCommand - (26) in 134.52µs

Browser Logs

None

Additional context

Here is the translation of your text into complete English, maintaining the technical context and structure:

This regression appears to be related to the dynamic definition analysis fallback (used when static analysis fails, likely triggered here because the resulting type is complex/dynamic).

After some debugging, I found that the issue might be within:

while !ancestor.is::<ast::LetBinding>() {

I inserted some logs here to observe the behavior of this while loop:

            while !ancestor.is::<ast::LetBinding>() {
                println!("itered, ancestor is {:?}", ancestor);
                ancestor = ancestor.parent()?.clone();
            }

The result is:

itered, ancestor is Closure: 83 [Params: 3 [Ident: "arg"], Space: " ", Arrow: "=>", Space: " ", Conditional: 76 [If: "if", Space: " ", Binary: 6 [Ident: "n", Space: " ", EqEq: "==", Space: " ", Int: "1"], Space: " ", CodeBlock: 19 [LeftBrace: "{", Space: "\n    ", Code: 9 [FuncCall: 9 [Ident: "func", Args: 5 [LeftParen: "(", Ident: "arg", RightParen: ")"]]], Space: "\n  ", RightBrace: "}"], Space: " ", Else: "else", Space: " ", CodeBlock: 41 [LeftBrace: "{", Space: "\n    ", Code: 31 [FuncCall: 31 [Ident: "currifyS", Args: 23 [LeftParen: "(", Binary: 5 [Ident: "n", Space: " ", Minus: "-", Space: " ", Int: "1"], Comma: ",", Space: " ", FuncCall: 14 [FieldAccess: 9 [Ident: "func", Dot: ".", Ident: "with"], Args: 5 [LeftParen: "(", Ident: "arg", RightParen: ")"]], RightParen: ")"]]], Space: "\n  ", RightBrace: "}"]]]
itered, ancestor is Code: 119 [FuncCall: 33 [Ident: "assert", Args: 27 [LeftParen: "(", Binary: 25 [Binary: 14 [FuncCall: 7 [Ident: "type", Args: 3 [LeftParen: "(", Ident: "n", RightParen: ")"]], Space: " ", EqEq: "==", Space: " ", Ident: "int"], Space: " ", And: "and", Space: " ", Binary: 6 [Ident: "n", Space: " ", GtEq: ">=", Space: " ", Int: "1"]], RightParen: ")"]], Space: "\n  ", Closure: 83 [Params: 3 [Ident: "arg"], Space: " ", Arrow: "=>", Space: " ", Conditional: 76 [If: "if", Space: " ", Binary: 6 [Ident: "n", Space: " ", EqEq: "==", Space: " ", Int: "1"], Space: " ", CodeBlock: 19 [LeftBrace: "{", Space: "\n    ", Code: 9 [FuncCall: 9 [Ident: "func", Args: 5 [LeftParen: "(", Ident: "arg", RightParen: ")"]]], Space: "\n  ", RightBrace: "}"], Space: " ", Else: "else", Space: " ", CodeBlock: 41 [LeftBrace: "{", Space: "\n    ", Code: 31 [FuncCall: 31 [Ident: "currifyS", Args: 23 [LeftParen: "(", Binary: 5 [Ident: "n", Space: " ", Minus: "-", Space: " ", Int: "1"], Comma: ",", Space: " ", FuncCall: 14 [FieldAccess: 9 [Ident: "func", Dot: ".", Ident: "with"], Args: 5 [LeftParen: "(", Ident: "arg", RightParen: ")"]], RightParen: ")"]]], Space: "\n  ", RightBrace: "}"]]]]
itered, ancestor is CodeBlock: 125 [LeftBrace: "{", Space: "\n  ", Code: 119 [FuncCall: 33 [Ident: "assert", Args: 27 [LeftParen: "(", Binary: 25 [Binary: 14 [FuncCall: 7 [Ident: "type", Args: 3 [LeftParen: "(", Ident: "n", RightParen: ")"]], Space: " ", EqEq: "==", Space: " ", Ident: "int"], Space: " ", And: "and", Space: " ", Binary: 6 [Ident: "n", Space: " ", GtEq: ">=", Space: " ", Int: "1"]], RightParen: ")"]], Space: "\n  ", Closure: 83 [Params: 3 [Ident: "arg"], Space: " ", Arrow: "=>", Space: " ", Conditional: 76 [If: "if", Space: " ", Binary: 6 [Ident: "n", Space: " ", EqEq: "==", Space: " ", Int: "1"], Space: " ", CodeBlock: 19 [LeftBrace: "{", Space: "\n    ", Code: 9 [FuncCall: 9 [Ident: "func", Args: 5 [LeftParen: "(", Ident: "arg", RightParen: ")"]]], Space: "\n  ", RightBrace: "}"], Space: " ", Else: "else", Space: " ", CodeBlock: 41 [LeftBrace: "{", Space: "\n    ", Code: 31 [FuncCall: 31 [Ident: "currifyS", Args: 23 [LeftParen: "(", Binary: 5 [Ident: "n", Space: " ", Minus: "-", Space: " ", Int: "1"], Comma: ",", Space: " ", FuncCall: 14 [FieldAccess: 9 [Ident: "func", Dot: ".", Ident: "with"], Args: 5 [LeftParen: "(", Ident: "arg", RightParen: ")"]], RightParen: ")"]]], Space: "\n  ", RightBrace: "}"]]]], Space: "\n", RightBrace: "}"]
itered, ancestor is Closure: 145 [Ident: "currifyS", Params: 9 [LeftParen: "(", Ident: "n", Comma: ",", Space: " ", Ident: "func", RightParen: ")"], Space: " ", Eq: "=", Space: " ", CodeBlock: 125 [LeftBrace: "{", Space: "\n  ", Code: 119 [FuncCall: 33 [Ident: "assert", Args: 27 [LeftParen: "(", Binary: 25 [Binary: 14 [FuncCall: 7 [Ident: "type", Args: 3 [LeftParen: "(", Ident: "n", RightParen: ")"]], Space: " ", EqEq: "==", Space: " ", Ident: "int"], Space: " ", And: "and", Space: " ", Binary: 6 [Ident: "n", Space: " ", GtEq: ">=", Space: " ", Int: "1"]], RightParen: ")"]], Space: "\n  ", Closure: 83 [Params: 3 [Ident: "arg"], Space: " ", Arrow: "=>", Space: " ", Conditional: 76 [If: "if", Space: " ", Binary: 6 [Ident: "n", Space: " ", EqEq: "==", Space: " ", Int: "1"], Space: " ", CodeBlock: 19 [LeftBrace: "{", Space: "\n    ", Code: 9 [FuncCall: 9 [Ident: "func", Args: 5 [LeftParen: "(", Ident: "arg", RightParen: ")"]]], Space: "\n  ", RightBrace: "}"], Space: " ", Else: "else", Space: " ", CodeBlock: 41 [LeftBrace: "{", Space: "\n    ", Code: 31 [FuncCall: 31 [Ident: "currifyS", Args: 23 [LeftParen: "(", Binary: 5 [Ident: "n", Space: " ", Minus: "-", Space: " ", Int: "1"], Comma: ",", Space: " ", FuncCall: 14 [FieldAccess: 9 [Ident: "func", Dot: ".", Ident: "with"], Args: 5 [LeftParen: "(", Ident: "arg", RightParen: ")"]], RightParen: ")"]]], Space: "\n  ", RightBrace: "}"]]]], Space: "\n", RightBrace: "}"]]

This indicates that during the search, the very first ancestor already bypassed the target let binding and went directly to the line starting with arg => if n == 1 {.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions