Skip to content

Commit 7df3218

Browse files
authored
Merge pull request #1413 from herbie-fp/autofix-53-1
Automated Resyntax fixes
2 parents 4dceae1 + 1b2de82 commit 7df3218

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/api/demo.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@
439439
([entry (in-list json)])
440440
(match-define (list pt ex) entry)
441441
(unless (and (list? pt) (= (length pt) (length var-reprs)))
442-
(error 'json->pcontext "Invalid point ~a" pt))
442+
(raise-arguments-error 'json->pcontext "Invalid point" "pt" pt))
443443
(values (list->vector (map json->value pt var-reprs)) (json->value ex output-repr))))
444444
(mk-pcontext pts exs))
445445

src/api/sandbox.rkt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
(match command
168168
['improve
169169
(job-result command test 'timeout (*timeout*) (timeline-extract) #f (warning-log) #f)]
170-
[_ (error 'run-herbie "command ~a timed out" command)])))
170+
[_ (raise-arguments-error 'run-herbie "command timed out" "command" command)])))
171171

172172
(define (compute-result)
173173
(parameterize ([*timeline-disabled* (not timeline?)])
@@ -189,7 +189,7 @@
189189
['improve (get-alternatives test (get-sample test))]
190190
['local-error (get-local-error test pcontext)]
191191
['sample (get-sample test)]
192-
[_ (error 'compute-result "unknown command ~a" command)]))
192+
[_ (raise-arguments-error 'compute-result "unknown command" "command" command)]))
193193
(timeline-event! 'end)
194194
(define time (- (current-inexact-milliseconds) start-time))
195195
(job-result command test 'success time (timeline-extract) #f (warning-log) result))))

src/core/batch-reduce.rkt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,18 +220,17 @@
220220
(cons exact-pow
221221
(for/list ([term (cdr terms)])
222222
(cons (* a (car term)) (cdr term))))
223-
(cons 1
224-
(list* (cons a (batch-push! batch (car terms)))
225-
(for/list ([term (cdr terms)])
226-
(cons (* a (car term)) (cdr term))))))]
223+
(list* 1
224+
(cons a (batch-push! batch (car terms)))
225+
(for/list ([term (cdr terms)])
226+
(cons (* a (car term)) (cdr term)))))]
227227
[_ `(1 . ((1 . ,brf)))]))
228228
(batch-recurse batch gather-multiplicative-terms))
229229

230230
(define (combine-aterms terms)
231231
(define h (make-hash))
232232
(for ([term terms])
233-
(define sum (hash-ref! h (cadr term) 0))
234-
(hash-set! h (cadr term) (+ (car term) sum)))
233+
(hash-update! h (cadr term) (λ (sum) (+ (car term) sum)) 0))
235234
(sort (reap [sow]
236235
(for ([(k v) (in-hash h)]
237236
#:when (not (= v 0)))
@@ -243,8 +242,7 @@
243242
(cons (car terms)
244243
(let ([h (make-hash)])
245244
(for ([term (cdr terms)])
246-
(define sum (hash-ref! h (cdr term) 0))
247-
(hash-set! h (cdr term) (+ (car term) sum)))
245+
(hash-update! h (cdr term) (λ (sum) (+ (car term) sum)) 0))
248246
(sort (reap [sow]
249247
(for ([(k v) (in-hash h)]
250248
#:unless (= v 0))

0 commit comments

Comments
 (0)