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

Deprecated annotation on let-binding does not trigger #7719

Closed
vicuna opened this issue Feb 2, 2018 · 9 comments
Closed

Deprecated annotation on let-binding does not trigger #7719

vicuna opened this issue Feb 2, 2018 · 9 comments

Comments

@vicuna
Copy link

vicuna commented Feb 2, 2018

Original bug ID: 7719
Reporter: authchir
Status: new
Resolution: open
Priority: normal
Severity: minor
Platform: amd64
OS: linux
OS Version: 4.4.0-43-Microso
Version: 4.06.0
Category: compiler driver
Monitored by: @nojb @gasche

Bug description

As explored in this [Stackoverflow question][1], a let-binding annotated with a deprecated annotation does not trigger any warning. But the annotation on type definition and constructors does work.

[1] https://stackoverflow.com/q/48579580/823955

Steps to reproduce

Given the following file main.ml:

let foo = (fun x -> x) [@@deprecated]
type t =
  | A [@deprecated]
  | B [@deprecated]
  [@@deprecated]

let _ = foo 0
let _ = A
let f (x : t) = x

The compilation output two warnings, while three would be expected:

$ ocamlc -w +3 main.ml
File "main.ml", line 8, characters 8-9:
Warning 3: deprecated: A
File "main.ml", line 9, characters 11-12:
Warning 3: deprecated: t
@vicuna
Copy link
Author

vicuna commented Jun 7, 2018

Comment author: @nojb

Related PR: #1822

@github-actions
Copy link

github-actions bot commented May 7, 2020

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label May 7, 2020
@Drup
Copy link
Contributor

Drup commented May 7, 2020

This bug is still present and relevant.

@avsm avsm removed the Stale label May 7, 2020
@github-actions
Copy link

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label May 12, 2021
@gasche gasche removed the Stale label May 12, 2021
@gasche
Copy link
Member

gasche commented May 12, 2021

The people who have looked most at alerts and warnings, and might look at this, are @alainfrisch and @lpw25. i don't know if other contributors ( @antalsz, @nchataing, @Drup ) would be interested in looking at it.

@nchataing
Copy link
Contributor

nchataing commented Jun 14, 2021

After some investigation, what comes clear is the fact that let f = (fun x -> x) [@@deprecated] puts the attribute on the value binding (see https://github.com/ocaml/ocaml/blob/trunk/typing/typedtree.ml#L296); however if we want the deprecated warning to fire, we need an attribute on the pattern inside the value binding (which would roughly correspond to Tpat_var "f" in this case).

The following code will hence emit the desired warning : let f[@deprecated] = fun x -> x in f 0.

@nchataing
Copy link
Contributor

After some thinking, one possible fix would be to propagate the deprecated attributes of a value binding inside its pattern, but it seems overly complicated (and it would certainly make typecore and typemod more complicated to follow).

@alainfrisch
Copy link
Contributor

In let x,y = (1, 2) [@@deprecated], which of x or yshould be marked as deprecated? I guess, both, but this shows pushing the alert from the whole binding to individual variables is not very natural.

As @nchataing mentioned, there is a syntax which works, and I'm tempted to believe that marking some components as deprecated within an implementation is rare enough (I've only seen case of deprecation markers in module signatures), so I'm not sure something needs to be fixed.

@github-actions
Copy link

github-actions bot commented Jul 1, 2022

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label Jul 1, 2022
@github-actions github-actions bot closed this as completed Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants