Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#385 closed defect (fixed)

Better error reporting for srfi-26

Reported by: sjamaan Owned by: felix winkelmann
Priority: minor Milestone: 4.9.0
Component: core libraries Version: 4.6.x
Keywords: srfi-26, cut, cute Cc:
Estimated difficulty:

Description

((cut + <...> 1) 1) is allowed and returns 1, contrary to expectations.

(cut) and (cute) both give an internal error; "Error: (car) during expansion of (cute ...) - bad argument type: ()". This should be a more contextually relevant error.

Here's two patches; one allows suffix patterns, the variables for which simply get consumed placewise from the right (similar to #379). Normal variables get consumed from the left and if anything's left in between, that's used for the placeholder. The above example would return 2.

The other patch simply checks for the presence of extra args and throws an error if there are any.

Both patches add an error message for when you do (cut).

Attachments (2)

srfi-26-extension.patch (7.2 KB) - added by sjamaan 14 years ago.
The version that adds an extension that allows tail patterns
srfi-26-error.patch (3.3 KB) - added by sjamaan 14 years ago.
New version of error-checking patch

Download all attachments as: .zip

Change History (13)

Changed 14 years ago by sjamaan

Attachment: srfi-26-extension.patch added

The version that adds an extension that allows tail patterns

comment:1 Changed 14 years ago by sjamaan

As you probably noticed, I also added the srfi-26 testcases from the srfi document to Chicken's test cases for future hacking on it.

comment:2 Changed 14 years ago by sjamaan

By the way, if chop from data-structures or take-right and drop-right from srfi-1 would be available in the syntax code, both this and #379 could be simplified (and this one would be a little more efficient, I suppose).

comment:3 Changed 14 years ago by sjamaan

Damn you, Trac

comment:4 Changed 14 years ago by sjamaan

By the way: I considered adding the extension because currently we have no real alternative for the now removed left-section & right-section (unless I'm missing something, which is quite possible). This extension would allow the following conversion:

((left-section list 1 2 3) 4 5 6) <=> ((cut list 1 2 3 <...>) 4 5 6)
((right-section list 4 5 6) 1 2 3) <=> ((cut list <...> 4 5 6) 1 2 3)

comment:5 Changed 14 years ago by felix winkelmann

the error-checking patch has been applied (experimental).

comment:6 in reply to:  5 Changed 14 years ago by felix winkelmann

Replying to felix:

the error-checking patch has been applied (experimental).

Doesn't compile.

Changed 14 years ago by sjamaan

Attachment: srfi-26-error.patch added

New version of error-checking patch

comment:7 Changed 14 years ago by sjamaan

Sorry about that. I replaced it with one that does work.

(of course, secretly, I sabotaged this one hoping you'd apply the more feature-rich one...But you foiled the plan!)

comment:8 in reply to:  7 Changed 14 years ago by felix winkelmann

Replying to sjamaan:

Sorry about that. I replaced it with one that does work.

Thanks - now it has been committed.

comment:9 Changed 14 years ago by sjamaan

Resolution: fixed
Status: newclosed

OK, then I'll close this

comment:10 Changed 13 years ago by felix winkelmann

Milestone: 4.7.04.8.0

Milestone 4.7.0 deleted

comment:11 Changed 11 years ago by felix winkelmann

Milestone: 4.8.04.9.0

Milestone 4.8.0 deleted

Note: See TracTickets for help on using tickets.