list.remove_assoc doesn't work as expected.
-------------------------------------------

                 Key: LS-600
                 URL: http://dev.sourcefabric.org/browse/LS-600
             Project: Liquidsoap
          Issue Type: Bug
          Components: Liquidsoap
    Affects Versions: 1.0
            Reporter: MartinS4
            Priority: Major


Original code that led to the bug:

  dyn_sources :=
      list.append( [(uri,{ source.shutdown(s0) ; source.shutdown(output) ; 
print("removing for source id:") ; print(source.id(output)) ; 
print(sources_metadata_paths) ; sources_metadata_paths := 
list.remove_assoc(source.id(output), !sources_metadata_paths) ; 
print(sources_metadata_paths) ; delay := (-1.) })],
                    !dyn_sources )

Execution output:

removing for source id:
6d7d15f1-e4fb-4f92-b902-d9630470b3f5
ref([("6d7d15f1-e4fb-4f92-b902-d9630470b3f5","http://martin-virtualbox/titles";)])
ref([("6d7d15f1-e4fb-4f92-b902-d9630470b3f5","http://martin-virtualbox/titles";)])
 


And below David's answer that confirm/explain the bug:

OK, this is a bug. I could reproduce by using the primitive
list.remove(2,[2]) == [2]... Sorry about that. Please file a bug
report. My guess is that it relies on physical equality rather than
structural one.

In the meantime, here's a better implementation (straightforward, but
there might be typos...):
  list.remove_assoc =
   fun(x,l) -> list.fold_left(fun(l,y)->if fst(y)==x then l else
list.append([y],l) end,[],l)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://dev.sourcefabric.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Savonet-devl mailing list
Savonet-devl@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/savonet-devl

Répondre à