Skip to content

Commit c39271c

Browse files
committed
fixes for 459669f that were uncovered by drdr
1 parent 459669f commit c39271c

File tree

3 files changed

+48
-29
lines changed

3 files changed

+48
-29
lines changed

drracket-test/tests/drracket/syncheck-test.rkt

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,9 @@
579579
("lam" lexically-bound)
580580
("))\n (" default-color)
581581
("require" imported)
582-
(" 'm)\n " default-color)
582+
(" " default-color)
583+
("'m" unused-require)
584+
(")\n " default-color)
583585
("lam" imported)
584586
(")\n" default-color))
585587
'(((10 16) (20 26) (92 99))
@@ -985,11 +987,13 @@
985987
("module" imported)
986988
(" n racket " default-color)
987989
("list" imported)
988-
(") (module+ o " default-color)
990+
(") (" default-color)
991+
("module+" imported)
992+
(" o " default-color)
989993
("list" imported)
990994
("))" default-color))
991995
(list
992-
'((10 16) (18 24) (51 55))
996+
'((10 16) (18 24) (41 48) (51 55))
993997
'((27 33) (34 38))))
994998

995999
;; test case from Chongkai
@@ -1131,21 +1135,25 @@
11311135
("define" imported)
11321136
(" " default-color)
11331137
("red" lexically-bound)
1134-
(" 1)\n(module+ test " default-color)
1138+
(" 1)\n(" default-color)
1139+
("module+" imported)
1140+
(" test " default-color)
11351141
("red" imported)
11361142
(")" default-color))
11371143
'(((26 29) (47 50))
1138-
((6 17) (19 25) (30 30))))
1144+
((6 17) (19 25) (30 30) (34 41))))
11391145
(build-test "#lang racket/base\n(define 🏴‍☠️🏴‍☠️🏴‍☠️ 1)\n(module+ test 🏴‍☠️🏴‍☠️🏴‍☠️)"
11401146
'(("#lang racket/base\n(" default-color)
11411147
("define" imported)
11421148
(" " default-color)
11431149
("🏴‍☠️🏴‍☠️🏴‍☠️" lexically-bound)
1144-
(" 1)\n(module+ test " default-color)
1150+
(" 1)\n(" default-color)
1151+
("module+" imported)
1152+
(" test " default-color)
11451153
("🏴‍☠️🏴‍☠️🏴‍☠️" imported)
11461154
(")" default-color))
11471155
'(((26 38) (56 68))
1148-
((6 17) (19 25) (39 39))))
1156+
((6 17) (19 25) (39 39) (43 50))))
11491157

11501158
(build-test "#lang racket/base\n(require '#%kernel)\npair?"
11511159
'(("#lang racket/base\n(" default-color)

drracket-tool-text-lib/drracket/private/syncheck/contract-traversal.rkt

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
string-constants)
99
(provide annotate-contracts)
1010

11-
(define (annotate-contracts stx low-binders binding-inits)
11+
(define (annotate-contracts stx low-binders binding-inits binder+mods-binder)
1212
(define boundary-start-map (make-hash))
1313
(define internal-start-map (make-hash))
1414
(define domain-map (make-hash))
@@ -35,7 +35,8 @@
3535
coloring-plans already-jumped-ids
3636
low-binders binding-inits
3737
domain-map range-map
38-
#t)))
38+
#t
39+
binder+mods-binder)))
3940

4041
;; fill in the coloring-plans table for internal contracts
4142
(for ([(start-k start-val) (in-hash internal-start-map)])
@@ -44,7 +45,8 @@
4445
coloring-plans already-jumped-ids
4546
low-binders binding-inits
4647
domain-map range-map
47-
#f)))
48+
#f
49+
binder+mods-binder)))
4850

4951
;; enact the coloring plans
5052
(for ([(stx colors) (in-hash coloring-plans)])
@@ -61,7 +63,8 @@
6163

6264
(define (do-contract-traversal start-stx boundary-contract?
6365
coloring-plans already-jumped-ids
64-
low-binders binding-inits domain-map range-map polarity)
66+
low-binders binding-inits domain-map range-map polarity
67+
binder+mods-binder)
6568
(let ploop ([stx start-stx]
6669
[polarity polarity])
6770

@@ -87,11 +90,13 @@
8790
(for ([stx (in-list (hash-ref domain-map id '()))])
8891
(do-contract-traversal stx boundary-contract?
8992
coloring-plans already-jumped-ids
90-
low-binders binding-inits domain-map range-map (not polarity)))
93+
low-binders binding-inits domain-map range-map (not polarity)
94+
binder+mods-binder))
9195
(for ([stx (in-list (hash-ref range-map id '()))])
9296
(do-contract-traversal stx boundary-contract?
9397
coloring-plans already-jumped-ids
94-
low-binders binding-inits domain-map range-map polarity))]))]
98+
low-binders binding-inits domain-map range-map polarity
99+
binder+mods-binder))]))]
95100

96101
[else
97102
;; we didn't find a contract, but we might find one in a subexpression
@@ -125,7 +130,8 @@
125130
(cond
126131
[binders
127132
(base-color #'id polarity boundary-contract? coloring-plans)
128-
(for ([binder (in-list binders)])
133+
(for ([binder+mod (in-list binders)])
134+
(define binder (binder+mods-binder binder+mod))
129135
(base-color binder polarity boundary-contract? coloring-plans)
130136
(define visited? (free-id-table-ref already-jumped-ids binder #f))
131137
(unless visited?
@@ -164,10 +170,12 @@
164170
;; on one side will not pollute the other side.
165171
(do-contract-traversal #'b boundary-contract?
166172
coloring-plans already-jumped-ids
167-
low-binders binding-inits domain-map range-map polarity)
173+
low-binders binding-inits domain-map range-map polarity
174+
binder+mods-binder)
168175
(do-contract-traversal #'c boundary-contract?
169176
coloring-plans already-jumped-ids
170-
low-binders binding-inits domain-map range-map polarity)]
177+
low-binders binding-inits domain-map range-map polarity
178+
binder+mods-binder)]
171179
;; [(begin expr ...) (void)]
172180
[(begin0 fst rst ...)
173181
(ploop #'fst polarity)]
@@ -287,5 +295,5 @@
287295
(loop #'a)
288296
(loop #'b))]
289297
[x (void)]))
290-
(annotate-contracts expanded low-binders binding-inits)))
298+
(annotate-contracts expanded low-binders binding-inits values)))
291299

drracket-tool-text-lib/drracket/private/syncheck/traversals.rkt

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@
8989
sub-identifier-binding-directives)
9090
(annotate-contracts sexp
9191
(hash-ref phase-to-binders 0 (λ () (make-id-set 0)))
92-
(hash-ref binding-inits 0 (λ () (make-id-set 0))))
92+
(hash-ref binding-inits 0 (λ () (make-id-set 0)))
93+
binder+mods-binder)
9394
(when print-extra-info?
9495
(print-extra-info (list (list 'phase-to-binders phase-to-binders)
9596
(list 'phase-to-varrefs phase-to-varrefs)
@@ -913,17 +914,19 @@
913914
(for ([binder+mods (in-list binders)])
914915
(define binder (binder+mods-binder binder+mods))
915916
(define binder-is-outside-reference?
916-
(let loop ([mods-where-var-is (reverse mods-where-var-is)]
917-
[mods-where-binder-is (reverse (binder+mods-mods binder+mods))])
918-
(cond
919-
[(null? mods-where-binder-is) #t]
920-
[(null? mods-where-var-is) #f]
921-
[else
922-
(define mod (car mods-where-var-is))
923-
(and (submodule-enclosing-bindings-visible? mod)
924-
(equal? mod (car mods-where-binder-is))
925-
(loop (cdr mods-where-var-is)
926-
(cdr mods-where-binder-is)))])))
917+
(or (not mods-where-var-is)
918+
(not (binder+mods-mods binder+mods))
919+
(let loop ([mods-where-var-is (reverse mods-where-var-is)]
920+
[mods-where-binder-is (reverse (binder+mods-mods binder+mods))])
921+
(cond
922+
[(null? mods-where-binder-is) #t]
923+
[(null? mods-where-var-is) #f]
924+
[else
925+
(define mod (car mods-where-var-is))
926+
(and (submodule-enclosing-bindings-visible? mod)
927+
(equal? mod (car mods-where-binder-is))
928+
(loop (cdr mods-where-var-is)
929+
(cdr mods-where-binder-is)))]))))
927930
(when binder-is-outside-reference?
928931
(connect-syntaxes binder var actual? all-binders phase-level connections #f))))
929932

0 commit comments

Comments
 (0)