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

path-type allow non-subtype struct acc #10

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
Jan 14, 2015
Merged

path-type allow non-subtype struct acc #10

merged 2 commits into from
Jan 14, 2015

Conversation

pnwamk
Copy link
Member

@pnwamk pnwamk commented Jan 10, 2015

fixes odd corner case internal errors where an alias's path doesn't check as a subtype of the type of the variable.

  1. For example error, download tar:
    https://www.dropbox.com/s/m0lj8n82z2xwogr/funky-typed.tar?dl=0

  2. untar

  3. racket funky-typed/synth/synth.rkt

With this commit, the internal error this currently triggers disappears and instead typechecking errors with a type mismatch on Array (this file does some non-standard usage of some of the private internals of the math/array library that doesn't work out). So both break, but this commit ensures it is a user level error for this case (i.e. a readable typechecker error) instead of a misleading internal path-mismatch error.

@samth
Copy link
Member

samth commented Jan 10, 2015

Can we make a test for this?

Also, can you use #:when instead of nevermind?

@pnwamk
Copy link
Member Author

pnwamk commented Jan 10, 2015

Okay, this initial fix is not right (I'll update the pull req in a sec if my next approach passes all the TR tests).

Here are two files which together produce the error when you run main.rkt:
foo.rkt https://gist.github.com/andmkent/eba07d62b322e2fac3e2
main.rkt (requires foo.rkt) https://gist.github.com/andmkent/11b14797f3b6cb03f717

Someone who is better at modules could probably turn this into a test right quick. I can probably figure out how to with some more tinkering...

Basically, this code (which is a simpler version of the funkytown code) involves a module ("foo.rkt") which exports a macro ("in-foo") which references a struct ("foo") defined in that module also, however that struct ("foo") is not exported. When another module ("main.rkt") imports and uses that macro ("in-foo"), it is typechecking code which is doing type-tests and unsafe-struct accesses on a struct it doesn't even have a type for. This would normally error with a type checking error (user level) -- let aliasing got involved because it made some aliases to struct-path objects before the "foo is an unbound type" errors kicked in and instead it hit that internal error (which was annoying! Why didn't that "foo unbound" error get thrown sooner? Then this (probably) wouldn't have been an issue at all!).

Andrew Kent added 2 commits January 10, 2015 15:10
@pnwamk
Copy link
Member Author

pnwamk commented Jan 10, 2015

So, because the internal error in path-type was getting called before the proper typechecking errors were being reported, I tried returning the "Error" type if path-type is unable to extract a type -- this worked, causing all the code which was triggering the internal error to instead give the proper user-level typechecking errors. All TR test cases are passing.

pnwamk pushed a commit that referenced this pull request Jan 14, 2015
path-type now allows normal internal errors
@pnwamk pnwamk merged commit 8c5c032 into racket:master Jan 14, 2015
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.

2 participants