Skip to content
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

Decorate values with arbitrary warnings #3248

Merged
merged 23 commits into from
Mar 9, 2022

Conversation

kustosz
Copy link
Contributor

@kustosz kustosz commented Feb 2, 2022

Pull Request Description

This introduces the runtime support for transparent values decorated with arbitrary warning values.
It is the first part of the warnings task, as these warnings do not currently carry any meta-information regarding code locations. This will be added in the next PR.

Important Notes

There are no slowdowns in the java benchmark suite.

Checklist

Please include the following checklist in your PR:

  • The documentation has been updated if necessary.
  • All code conforms to the Scala, Java, and Rust style guides.
  • All documentation and configuration conforms to the markdown and YAML style guides.
  • All code has been tested where possible.

@kustosz
Copy link
Contributor Author

kustosz commented Feb 2, 2022

Forgot to mention, there's also a new test utility: if an env variable called TEST_ONLY_GROUP contains a regexp, only test groups matching the regexp will run.

Copy link
Member

@wdanilo wdanilo left a comment

Choose a reason for hiding this comment

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

That's amazing!

  1. I'm starting loving our testing jokes :D
    image

  2. I don't see tests for setting a list of warnings or cleaning them, I see only tests for getting the list and attaching warnings – am I missing something.

  3. It's absolutely amazing there are no perf hits!

Copy link
Member

@jdunkerley jdunkerley left a comment

Choose a reason for hiding this comment

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

This looks fantastic.

And thanks for the test framework improvement too - I'd been thinking of doing similarly.

Comment on lines 15 to 19
Test.specify "should allow to attach multiple warnings and read them back" <|
x = 1233
y = Warning.attach x "don't do this"
z = Warning.attach y "I'm serious"
here.get_warnings z . should_equal ["I'm serious", "don't do this"]
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't attach at the new warnings at the back instead of at the front?

Makes sense if we want warnings to go LIFO, but then it seems inconsistent with how in the expression: a+b technically a is computed first, but its warning also goes first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Newest warning goes first. Though, I'll probably end up having a logical clock for these, when I actually implement the warnings functionality. This is just to have a notion of tainting values with stuff, the user-facing part is to be implemented.

@kustosz
Copy link
Contributor Author

kustosz commented Feb 3, 2022

  1. I don't see tests for setting a list of warnings or cleaning them, I see only tests for getting the list and attaching warnings – am I missing something.

@wdanilo yeah, you're missing the fact this is an internal API only, mostly to make sure I can actually get away with value-tainting. This does not implement the user-facing API yet.

@kustosz kustosz marked this pull request as draft February 17, 2022 13:03
@kustosz kustosz force-pushed the compiler/wip/mk/dataflow-warnings branch from 5b62f24 to 24179c1 Compare February 17, 2022 13:11
@kustosz kustosz marked this pull request as ready for review March 4, 2022 15:26
attach value warning = @Builtin_Method "Prim_Warning.attach"

get_all : Any -> Vector.Vector
get_all value = @Builtin_Method "Prim_Warning.get_all"
Copy link
Member

Choose a reason for hiding this comment

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

There are a few methods missing from this list get_origin and get_reassignments.


public static WithWarnings appendTo(Object target, ArrayRope<Warning> warnings) {
if (target instanceof WithWarnings) {
return new WithWarnings(((WithWarnings) target).warnings.append(warnings));
Copy link
Member

Choose a reason for hiding this comment

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

Think this should just be:
return ((WithWarnings) target).warnings.append(warnings);
If I am reading it right otherwise would double nest the value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, something went very wrong here, good catch :)

Copy link
Member

@jdunkerley jdunkerley left a comment

Choose a reason for hiding this comment

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

Couple of little things to check but otherwise LGTM

@kustosz kustosz merged commit 4653bfe into develop Mar 9, 2022
@kustosz kustosz deleted the compiler/wip/mk/dataflow-warnings branch March 9, 2022 15:40
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.

5 participants