这是indexloc提供的服务,不要输入任何密码
Skip to content

fix issue #169 #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 15, 2015
Merged

fix issue #169 #170

merged 2 commits into from
Aug 15, 2015

Conversation

AlexKnauth
Copy link
Member

fixes #169

@@ -266,7 +266,7 @@
;; [(_ (Univ:)) A0]
;; error is top and bot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, does this mean this comment here is no longer true?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. I think it means that it is only top now. I'm not sure why it would be bot in the first place, but changing this seems to break more tests, so I'm not sure how this should work.

@samth
Copy link
Member

samth commented Aug 5, 2015

This is not the right change. Error is intended to be allowable anywhere, and only generated when there is a type error to prevent additional downstream type errors. If in #169 there's an Error generated, then we should figure out why there's no type error resulting from that.

@AlexKnauth
Copy link
Member Author

Ok. I just hadn't expected the subtype check here (https://github.com/AlexKnauth/typed-racket/blob/fix/typed-racket-lib/typed-racket/infer/infer-unit.rkt#L483) to succeed, and that was what caused #169 .

I'll look for another way to solve this then.

@AlexKnauth
Copy link
Member Author

@samth Is the parse-type here (

(define rep-ty (parse-type (attribute form.rep-type)))
) the right way to do this?

Could that be what's causing Error to appear here for user-defined types? Is there a better way of doing this that avoids that?

@AlexKnauth
Copy link
Member Author

Re: parse-type, maybe not. I put a printf in there, and parse-type is returning the right thing (Pos not Error). So I have no idea where the Error type is coming from.

@AlexKnauth
Copy link
Member Author

Nope. I was wrong. parse-type is returning Error, but I got thrown off because it was printing as Pos, even though it matches the pattern (Error:). So, is there something else I should be using instead of parse-type?

@samth
Copy link
Member

samth commented Aug 12, 2015

The printing issue is almost certainly because we end up with Pos aliased to Error.

Do you know why parse-type is failing?

@AlexKnauth
Copy link
Member Author

No I don't.

@samth
Copy link
Member

samth commented Aug 12, 2015

I think that's the first thing to investigate.

@AlexKnauth
Copy link
Member Author

It seems like the Error type (still printed as Pos) is in the mapping table before I even call parse-type, and that's where it's coming from. But how did that get there?

@AlexKnauth
Copy link
Member Author

Oh. It gets filled with all error types, and then replaced with the correct types later.

@AlexKnauth AlexKnauth force-pushed the fix branch 2 times, most recently from a1190e1 to 50a7294 Compare August 12, 2015 20:26
@AlexKnauth
Copy link
Member Author

Ok I took a completely different approach and it's working now.

@@ -0,0 +1,10 @@
#;
(exn-pred #rx"expected: (Listof Nothing).*given: (Listof Pos*)")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, except the parens and * probably aren't good in the regexp there.

@AlexKnauth
Copy link
Member Author

How does this look now?

@@ -17,7 +17,7 @@
(define-other-types
-> ->* case-> U Rec All Opaque Vector
Parameterof List List* Class Object Values Instance Refinement
pred Struct Struct-Type Prefab Top Bot)
pred Struct Struct-Type Prefab Top Bot Distinction)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this now exposed to users? What does it correspond to?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, now I think I understand. Why not create a new internal form, instead of a new type constructor that isn't exposed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't think of any other way to allow both new-subtypes to refer to type aliases and for other forms to refer to new-subtypes properly.

But actually, this still is broken, in this example:

#lang typed/racket/base
(define-new-subtype Lst (make-Lst (U Null (Pairof Elt Lst))))
(define-new-subtype Elt (make-Elt (U Symbol Lst)))
(: cns : Elt Lst -> (Pairof Elt Lst))
(define cns
  (inst cons Elt Lst))
(: lst : Elt * -> Lst)
(define (lst . args)
  (for/fold ([lst (make-Lst '())]) ([elt (in-list (reverse args))])
    (make-Lst (cns elt lst))))

With this error highlighting the lst in the for/fold accumulator:

. Type Checker: type mismatch
  expected: Lst
  given: Lst in: lst

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'm confused why the work done by this define-type-alias form can't be done manually in define-new-subtype/pass1.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I am not sure that we even want to support recursive uses of new-subtype like this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it might be because I never allowed Distinction types to be subtypes of themselves.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, still broken, even with that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably @takikawa is the right person to help with recursive aliases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I just fixed it. There was a missing call to resolve in there, and that fixed it. I also added a version of that example as another test.

@AlexKnauth AlexKnauth force-pushed the fix branch 2 times, most recently from 6104fe0 to 47266cf Compare August 14, 2015 18:06
@AlexKnauth
Copy link
Member Author

The travis build is passing now, thanks to #175

@AlexKnauth AlexKnauth merged commit af2c22f into racket:master Aug 15, 2015
@AlexKnauth AlexKnauth deleted the fix branch August 15, 2015 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug with define-new-subtype and for*/list (and inference)
3 participants