SourceKitten icon indicating copy to clipboard operation
SourceKitten copied to clipboard

Could not cast value of type 'Swift.String' (0x7ff8556a6848) to 'Swift.Dictionary<Swift.String, SourceKittenFramework.SourceKitRepresentable>' (0x7ff855e42708).

Open david-hm-morgan opened this issue 1 year ago • 1 comments

Please can anyone help to find a solution or workaround to an issue like this?

Could not cast value of type 'Swift.String' (0x7ff8556a6848) to 'Swift.Dictionary<Swift.String, SourceKittenFramework.SourceKitRepresentable>' (0x7ff855e42708).

	from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/lib/jazzy/sourcekitten.rb:229:in `run_sourcekitten'
	from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/lib/jazzy/doc_builder.rb:83:in `block (2 levels) in build'
	from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/lib/jazzy/doc_builder.rb:81:in `chdir'
	from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/lib/jazzy/doc_builder.rb:81:in `block in build'
	from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/lib/jazzy/doc_builder.rb:71:in `map'
	from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/lib/jazzy/doc_builder.rb:71:in `build'
	from /Users/jenkins/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/jazzy-0.15.1/bin/jazzy:16:in `<top (required)>'
	from /Users/jenkins/.rbenv/versions/3.2.2/bin/jazzy:25:in `load'
	from /Users/jenkins/.rbenv/versions/3.2.2/bin/jazzy:25:in `<main>'

Using:

  • Xcode 16.0
  • Sourcekitten 0.36.0
  • rbenv 3.2.2
  • jazzy version: 0.15.1

david-hm-morgan avatar Sep 16 '24 12:09 david-hm-morgan

See https://github.com/realm/jazzy/issues/1399 pinpointing a crash in SourceKitten

david-hm-morgan avatar Sep 17 '24 13:09 david-hm-morgan

Hello. I found workaround for similar problem.

> sourcekitten doc --single-file example.swift

Could not cast value of type 'Swift.String' (0x1f051c2b0) to 'Swift.Dictionary<Swift.String, SourceKittenFramework.SourceKitRepresentable>' (0x1ee63a878).
[1]    20033 abort      sourcekitten doc --single-file example.swift

example.swift file content:

struct T {
    private (set) var a: Int?
}

For fix problem just remove space between private and (set).

UPD: found error explanation with debugger:

extraneous whitespace between attribute name and '('; this is an error in the Swift 6 language mode

ZGl6YXNt avatar Oct 13 '24 07:10 ZGl6YXNt

@ZGl6YXNt that's brilliant, thank you for adding this.

Apple have broken/changed the unwritten sourcekit output rules with their "educational notes" diagnostic feature, I think for now is OK to tolerate arrays of Strings. Just need to review a bit to see if there's anywhere else this could affect.

johnfairh avatar Oct 13 '24 20:10 johnfairh