-
Notifications
You must be signed in to change notification settings - Fork 275
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
Produce more helpful output when module output is overwritten #716
base: main
Are you sure you want to change the base?
Conversation
807587a
to
c030424
Compare
c030424
to
e756a15
Compare
@@ -0,0 +1 @@ | |||
output: String = "abc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally this problem would be caught right here (override with different type), but I guess that's impossible for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd like to make Pkl stricter here and enforce that subclasses are also subtypes. Maybe something to do before we cut a 1.0 release.
Co-authored-by: translatenix <[email protected]>
cb37adb
to
9d40f6d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Generally, this is the right approach. See comments for some minor issues here.
@@ -0,0 +1,3 @@ | |||
class Test {} | |||
|
|||
output: Test = new {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this and invliadOutput1
to input/errors
.
I know we have some other error tests in input/modules
, but those should probably be moved too. The intention is to put all testing around error messages in the errors/
dir.
@@ -0,0 +1 @@ | |||
output: String = "abc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd like to make Pkl stricter here and enforce that subclasses are also subtypes. Maybe something to do before we cut a 1.0 release.
Object value, | ||
VmTyped container, | ||
Identifier propertyIdentifier, | ||
String propertyName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a fair bit of logic here that's bespoke to reading output.value
, so it's not too appropriate to be re-purposed. For example, it show different error messages based on whether output.value
was explicitly assigned or not.
I think we should just copy some of the logic here that's useful, and inline that into readModuleOutput
.
Just a note that covariant property types aren't sound: open class Foo { name: Any }
class Bar extends Foo { name: String } // covariant property type
bar: Bar = new { name = "bar" }
foo: Foo = bar
foo2: Foo = (foo) {
name = 123 // static type checker is happy
}
name = foo2.name // boom |
Yeah; unless they are marked either |
Evaluating this module:
Now produces
Resolves #709