Closed samth closed 1 year ago
The program below causes an internal error in the stepper. I haven't been able to usefully minimize it yet. The error message is:
recon-source: no matching clause for syntax: (quote-syntax ((movie-title s) ... (movie-year s) ... (movie-minutes s) ...) #:local)
The test engine report lists blank errors as the error that occurred.
If I remove everything after the "exercise 4" comment then the stepper error goes away but the test engine behavior is still weird.
; A Show is one of: ; - (make-movie String Number Number) ; - (make-sitcom String Number Number) (define-struct movie (title year minutes)) (define-struct sitcom (series season episode)) ;Here are some examples of a Show: (define show1 (make-movie "One Cut of the Dead" 2017 97)) (define show2 (make-sitcom "Rick and Morty" 2 6)) (define show3 (make-movie "Welt am Draht" 1973 205)) (define show4 (make-sitcom "Futurama" 4 15)) ;exercise1 (define (process-show s) (cond [(movie? s) (...(movie-title s)... (movie-year s)... (movie-minutes s)...)] [(sitcom? s) (...(sitcom-series s)... (sitcom-season s)... (sitcom-episode s)...)])) ;show-minutes: Show -> Number ;take a show and compute minute ;(define (show-minutes m)(...m..)) ;exercise 2 (check-expect (show-minutes (make-sitcom "Rick and Morty" 2 6))20) (check-expect (show-minutes (make-movie "One Cut of the Dead" 2017 97))97) (define (show-minutes s) (cond [(movie? s) (movie-minutes s)] [(sitcom? s)20])) ;exercise 3 ;show-name: Show -> String ;take the name of the show and produce a string ;(define (show-name sn)(...sn...)) (check-expect (show-name(make-movie "One Cut of the Dead" 2017 97)) "One Cut of the Dead (2017)") (check-expect (show-name (make-sitcom "Rick and Morty" 2 6)) "Rick and Morty S2E6") (define (show-name sn) (cond [(movie? sn) (string-append (movie-title sn)" " "("(number->string(movie-year sn))")")] [(sitcom? sn) (string-append (sitcom-series sn)" ""S" (number->string(sitcom-season sn)) "E"(number->string(sitcom-episode sn)))])) ;exercise 4 ; A Job is one of: ; - (make-entry Number) ; - (make-promotion Number Job) (define-struct entry[initial-salary]) (define-struct promotion[raise old-job]) ;exercise 5 (define firstJob(make-entry 100)) (define secondJob(make-promotion 200 (make-entry 100))) (define thirdJob(make-promotion 200 (make-promotion 100 (make-entry 50)))) ;exercise 6 (define (process-job j) (cond [(entry? j)(...(entry-initial-salary j)...)] [(promotion? j) (...(promotion-raise j) (process-job(promotion-old-job j)))])) ;exercise 7 ;salary: job -> Number ;take in a job and produce the salary of that kind of job ;(define (salary s)(...s...)) (check-expect (salary firstJob) 100) (check-expect (salary secondJob)300) (check-expect (salary thirdJob) 350) (define (salary j) (cond [(entry? j)(entry-initial-salary j)] [(promotion? j) (+ (promotion-raise j)(salary(promotion-old-job j)))])) ;exercise 8 ;pay-cut?: job -> Boolean ; take a job and see if the job receive any negative raise. (check-expect (pay-cut? (make-entry -100))false) (check-expect (pay-cut? (make-promotion 200 (make-entry 100)))false) (check-expect (pay-cut? (make-promotion -100 (make-entry 90)))true) (check-expect (pay-cut? (make-promotion -100 (make-entry -90)))true) (check-expect (pay-cut? (make-promotion 100 (make-entry -100)))false) (define (pay-cut? j) (cond [(entry? j)false] [(promotion? j) (cond [(< (promotion-raise j) 0)true] [else (pay-cut?(promotion-old-job j))])])) ;exercise 9 ;raise-amount is a number ;promote: job number -> job ;take a job and a raise amount produce a new job (check-expect (promote (make-entry 100) 100) (make-promotion 100 (make-entry 100))) (check-expect (promote (make-promotion 100 (make-entry 100))200) (make-promotion 200 (make-promotion 100 (make-entry 100)))) (check-expect (promote (make-promotion 200 (make-promotion 100 (make-promotion 300 (make-entry 100))))50) (make-promotion 50 (make-promotion 200 (make-promotion 100 (make-promotion 300 (make-entry 100)))))) (check-expect (promote (make-entry 100)0) (make-promotion 0 (make-entry 100))) (define (promote j n) (cond [(entry? j)(make-promotion n (make-entry(entry-initial-salary j)))] [(promotion? j) (make-promotion n(promote(promotion-old-job j)(promotion-raise j)))]))
Error originally reported by one of @ccshan's students.
Related: #168
(namely Jack Huynh)
The program below causes an internal error in the stepper. I haven't been able to usefully minimize it yet. The error message is:
The test engine report lists blank errors as the error that occurred.
If I remove everything after the "exercise 4" comment then the stepper error goes away but the test engine behavior is still weird.