Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.0.0-beta3
-
Fix Version/s: None
-
Component/s: Liquidsoap
-
Labels:None
Description
The following does not work:
output.dummy(
fallback([strip_blank(sine()), sine()]),
fallible=true)
I get:
this value has type
source(_)
but it should be a subtype of (the type of the value at line 1, char 35-42)
active_source(_)
It is my understanding that there should be no technical reasons to prohibit this and so there must be something to do at the type-checking level..
Edit: The problem is that type inference guesses that this is a list of active_sources, but the second one isn't active; we need a constraint-based type inference algorithm to integrate subtyping in smarter ways, eg. delay the guess until we've seen all elements.
output.dummy(
fallback([strip_blank(sine()), sine()]),
fallible=true)
I get:
this value has type
source(_)
but it should be a subtype of (the type of the value at line 1, char 35-42)
active_source(_)
It is my understanding that there should be no technical reasons to prohibit this and so there must be something to do at the type-checking level..
Edit: The problem is that type inference guesses that this is a list of active_sources, but the second one isn't active; we need a constraint-based type inference algorithm to integrate subtyping in smarter ways, eg. delay the guess until we've seen all elements.
Activity
David Baelde
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Assignee | David Baelde [ dbaelde ] |
David Baelde
made changes -
| Summary | fallback (and possibly other) refuses to start with a mixture of active and regular sources. | Type inference doesn't perform enough subtyping |
| Description |
The following does not work: output.dummy( fallback([strip_blank(sine()), sine()]), fallible=true) I get: this value has type source(_) but it should be a subtype of (the type of the value at line 1, char 35-42) active_source(_) It is my understanding that there should be no technical reasons to prohibit this and so there must be something to do at the type-checking level.. |
The following does not work: output.dummy( fallback([strip_blank(sine()), sine()]), fallible=true) I get: this value has type source(_) but it should be a subtype of (the type of the value at line 1, char 35-42) active_source(_) It is my understanding that there should be no technical reasons to prohibit this and so there must be something to do at the type-checking level.. Edit: The problem is that type inference guesses that this is a list of active_sources, but the second one isn't active; we need a constraint-based type inference algorithm to integrate subtyping in smarter ways, eg. delay the guess until we've seen all elements. |
David Baelde
made changes -
| Priority | Blocker [ 1 ] | Major [ 3 ] |
Romain Beauxis
made changes -
| Affects Version/s | 1.0.0-beta3 [ 10478 ] | |
| Affects Version/s | 1.0 beta [ 10311 ] |
| List l ->
List.iter (check ~level ~env) l ;
let pos =
(* Attach the position of the first item in the list
* to the type of the list items. It gives more info with type errors
* when the items in the list are not compatible.
* WARNING This will become weird with real subtyping in the inference,
* because the type of elements will only be _a supertype_ of the type
* of the first item. *)
match l with e::_ -> e.t.T.pos | [] -> e.t.T.pos
in
let v = T.fresh_evar ~level ~pos in
e.t >: mk (T.List v) ;
List.iter (fun item -> item.t <: v) l
If I change the previous example to:
output.dummy(
fallback([fail(), strip_blank(sine()), sine()]),
fallible=true)
Then it works..