apple / sourcekit-lsp

Language Server Protocol implementation for Swift and C-based languages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Malformed `compile_commands.json` causes crash

z2oh opened this issue · comments

tryLoadCompilationDatabase fails aggressively if it finds a compile_commands.json but fails to parse it:

SKCore/CompilationDatabase.swift:84: Fatal error: 'try!' expression unexpectedly raised an error: Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Foundation.JSONError.unexpectedEndOfFile)))

Simple repro:

touch A.swift
touch compile_commands.json
code .

The language server crashes on startup.

Tracked in Apple’s issue tracker as rdar://120804823