Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with type inference: detecting Mixed but requiring [Mixed] #112

Closed
DamienCassou opened this issue Oct 31, 2018 · 3 comments
Closed

Comments

@DamienCassou
Copy link
Contributor

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].

@Fuco1
Copy link
Member

Fuco1 commented Oct 31, 2018

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.

@Fuco1
Copy link
Member

Fuco1 commented Oct 31, 2018

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.

@DamienCassou DamienCassou changed the title Problem with type inference: detecting Mixed but requiring Mixed Problem with type inference: detecting Mixed but requiring [Mixed] Nov 1, 2018
@Fuco1
Copy link
Member

Fuco1 commented Feb 14, 2023

The OP example now works correctly.

@Fuco1 Fuco1 closed this as completed Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants