You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
copilot-language - Unable to drop as many elements from Stream as prepended #607
The elements must be realizable at the present time to be able to drop elements. For most kinds of streams, you cannot drop elements without prepending an equal or greater number of elements to them first, as it could result in undefined samples.
Since the document states that prepending 'equal' number of elements suffices, I expected the following code to compile
changed the title [-]`copilot-language` - unable to drop as many element as prepended[/-][+]`copilot-language` - Unable to drop as many elements from Stream as prepended[/+]on Mar 11, 2025
The documentation for copilot-language's drop function claims that one can drop a number of elements from a stream equal to the number of elements prepended to the stream. In practice, this is not the case, and copilot-language's analysis will reject such uses of drop.
Type
Bug: implementation does not match the documented behavior.
Additional context
None.
Requester
Ryan Scott (Galois)
Method to check presence of bug
Run the following Copilot specification:
{-# LANGUAGE NoImplicitPrelude #-}
moduleMain (main) whereimportLanguage.Copilotspec::Spec
spec =dolet s ::StreamBool
s =drop2 ([False, False] ++ true)
trigger "example" s [arg s]
main::IO()
main = interpret 5 spec
This specification will be rejected with the following error message:
$ runghc Bug.hs
Bug.hs: Copilot error: Drop index overflow!
CallStack (from HasCallStack):
error, called at src/Copilot/Language/Error.hs:24:16 in copilot-language-4.3-inplace:Copilot.Language.Error
Expected result
Running the Copilot specification above should succeed, and the Copilot interpreter should print five true samples.
Desired result
Running the Copilot specification above should succeed, and the Copilot interpreter should print five true samples.
Proposed solution
Modify the implementation of drop to add a special case for when the drop length equals the number of elements prepended to a stream with an Append, which will return the underlying stream.
Activity
[-]`copilot-language` - unable to drop as many element as prepended[/-][+]`copilot-language` - Unable to drop as many elements from Stream as prepended[/+]strikef commentedon Mar 12, 2025
copilot/copilot-language/src/Copilot/Language/Analyze.hs
Line 191 in e042933
It appears that
analyzeDropis throwing DropIndexOverflow even when |drop| == |append|. Could this be the culprit?RyanGlScott commentedon Feb 13, 2026
Description
The documentation for
copilot-language'sdropfunction claims that one can drop a number of elements from a stream equal to the number of elements prepended to the stream. In practice, this is not the case, andcopilot-language's analysis will reject such uses ofdrop.Type
Additional context
None.
Requester
Method to check presence of bug
Run the following Copilot specification:
{-# LANGUAGE NoImplicitPrelude #-} module Main (main) where import Language.Copilot spec :: Spec spec = do let s :: Stream Bool s = drop 2 ([False, False] ++ true) trigger "example" s [arg s] main :: IO () main = interpret 5 specThis specification will be rejected with the following error message:
Expected result
Running the Copilot specification above should succeed, and the Copilot interpreter should print five
truesamples.Desired result
Running the Copilot specification above should succeed, and the Copilot interpreter should print five
truesamples.Proposed solution
Modify the implementation of
dropto add a special case for when the drop length equals the number of elements prepended to a stream with anAppend, which will return the underlying stream.Further notes
None.
copilot-language: Report exceptions as failures in drop tests. Refs C…