Coder Social home page Coder Social logo

Comments (23)

chenglou avatar chenglou commented on June 16, 2024 1

Hey Josh. Unrelated but glad to see you again =)

from reanalyze.

cristianoc avatar cristianoc commented on June 16, 2024 1

So for now it seems that indeed treating 42 as @live is the way forward.

from reanalyze.

cristianoc avatar cristianoc commented on June 16, 2024 1

I’d have first to make it slower, to give an excuse.

from reanalyze.

cristianoc avatar cristianoc commented on June 16, 2024

I guess this falls in the category: it is dead, it should be considered dead, but should not be reported as dead.
Not sure I'd want to consider global options, only these local @@@ocaml.warning "-32". Which makes it an ad-hoc treatment. Also, not clear how to get hold of global options anyway. So one would observe a difference when disabling 32 in the command line, and in the code.

The PPX magic comes to bite back in many subtle ways.

from reanalyze.

jberdine avatar jberdine commented on June 16, 2024

Yes: dead but shouldn't be reported. But it is dead in the [@live] sense rather than the [@dead] one, since such code might be the only use of other code, and that other code should not be reported dead.

Considering only the attributes seems pragmatically sensible, since it isn't clear what the use case might be for compiling with -w -32 and expecting dead code analysis to not be noisy.

FWIW, I don't think that this really has anything crucially to do with ppx. Warning 32 predates ppx, and there are reasonable cases where e.g. a codebase's style mandates that each type comes with a common set of operations like compare and hash.

Also, it is probably a good idea to handle the other "unused" warnings similarly. Maybe 32-39, 60, 66.

from reanalyze.

jberdine avatar jberdine commented on June 16, 2024

edit: s/dead/not dead/

from reanalyze.

cristianoc avatar cristianoc commented on June 16, 2024

There’s also the automatic deletion of dead code. And for that one would like to delete even things kept alive only by this.
But it’s not a big issue. I’ll keep it simple.

from reanalyze.

jberdine avatar jberdine commented on June 16, 2024

Ok, but for automatic deletion of dead code it's a ppx that outputs a new parsetree right, so no need to change the source, just give it to the rest of the compiler.

from reanalyze.

cristianoc avatar cristianoc commented on June 16, 2024

Currently the analysis adds annotations, and the deletion ppx runs afterwards. So there’s a limit anyway to what can be done with that setup, as you can’t annotate code generated by a ppx.
A fuller solution would require deep integration in the compiler, as typed ast to typed ast xform.

from reanalyze.

jberdine avatar jberdine commented on June 16, 2024

Currently the analysis adds annotations

Does this work by adding attributes to the parsetree? If so, it would be rolled into one ppx pipeline and not have to worry about whether code was generated or not.

from reanalyze.

cristianoc avatar cristianoc commented on June 16, 2024

No it’s literally printing into the source file.
So it’s very easy to take a quick look at a project without going through the list of reported issues.

from reanalyze.

cristianoc avatar cristianoc commented on June 16, 2024

Btw the analysis operates on the typed tree. Does not fit a ppx pipeline.

from reanalyze.

jberdine avatar jberdine commented on June 16, 2024

Ah, yes, I knew but overlooked that. It would be a bit of work then to get back to the untyped tree, or construct a new one, or... Hmm. I suspect that you could reuse the implementation technique of ppx_import though, as it reads cmt files and generates code. That needs to use the staged_pps instead of pps flow in dune, but that should also be doable for reanalyze I think.

from reanalyze.

cristianoc avatar cristianoc commented on June 16, 2024

The analysis is global so strictly speaking does not fit in the ppx flow by that reason alone. However of course it could store the results somewhere then run a ppx that reads them.

from reanalyze.

jberdine avatar jberdine commented on June 16, 2024

from reanalyze.

cristianoc avatar cristianoc commented on June 16, 2024

@jberdine this is done in #13.
Unsure about whether to support other suppressions beyond 32. What did you have in mind?

from reanalyze.

cristianoc avatar cristianoc commented on June 16, 2024

A relevant one is 34 Unused type declaration. Though that's a bit different from the sense in which variant/records parts are unused.
Merging this for now.

from reanalyze.

jberdine avatar jberdine commented on June 16, 2024

The following might also make sense:
37 Unused constructor.
38 Unused extension constructor.
60 Unused module declaration.

from reanalyze.

jberdine avatar jberdine commented on June 16, 2024

It seems that code like

let[@warning "-32"] foo x = print_int x

still gets flagged if foo is otherwise dead.

from reanalyze.

cristianoc avatar cristianoc commented on June 16, 2024

Let me check.

from reanalyze.

cristianoc avatar cristianoc commented on June 16, 2024

Tried to repro the example here:
#22

No cigar.

What was the example?

from reanalyze.

cristianoc avatar cristianoc commented on June 16, 2024

Oh wait warning not ocaml.warning?

from reanalyze.

jberdine avatar jberdine commented on June 16, 2024

Yes, they are synonyms.

from reanalyze.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.