Elsa
Elsa copied to clipboard
Problem with type inference: detecting Mixed but requiring [Mixed]
This code (part of libmpdel.el) doesn't pass Elsa analysis but works great in practice:
(defun libmpdel--create-song-from-data (song-data)
"Return a song from SONG-DATA, a server's response."
(libmpdel--song-create
:name (cdr (assq 'Title song-data))
:track (cdr (assq 'Track song-data))
:file (cdr (assq 'file song-data))
:album (libmpdel--album-create
:name (cdr (assq 'Album song-data))
:artist (libmpdel--artist-create :name (cdr (assq 'Artist song-data))))
:date (cdr (assq 'Date song-data))
:disc (cdr (assq 'Disc song-data))
:id (cdr (assq 'Id song-data))
:pos (cdr (assq 'Pos song-data))))
Elsa detects a problem at each line where assq is used:
Argument 2 accepts type [Mixed] but received Mixed
For some reason, song-data is considered Mixed and not [Mixed].
All arguments are by default assumed to be Mixed. Once the type inference is better this code should work OK since the first call the assq would update song-data to be an array.
I have an experimental branch at home which should fix this. I can push it later today and you can have a look.
Thanks for all the feedback by the way, much appreciated. It's nice to see some of the real issues people run into. These should be priorities when fixing stuff so it's as usable as possible as fast as possible.