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

ocaml.ppwarning ignored in the toplevel #7081

Closed
vicuna opened this issue Dec 9, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link

commented Dec 9, 2015

Original bug ID: 7081
Reporter: @sliquister
Assigned to: @diml
Status: closed (set by @xavierleroy on 2017-02-16T14:18:16Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.3
Fixed in version: 4.03.0+dev / +beta1
Category: ~DO NOT USE (was: OCaml general)

Bug description

The toplevel ignores [@ocaml.ppwarning ".."], which is quite confusing.

Steps to reproduce

$ cat /tmp/a.ml
1 [@ppwarning "asd"];;
$ ocaml /tmp/a.ml
$ ocamlc /tmp/a.ml
File "/tmp/a.ml", line 1, characters 14-19:
Warning 22: asd

@vicuna

This comment has been minimized.

Copy link
Author

commented Dec 9, 2015

Comment author: @sliquister

Presumably Typemod.type_toplevel_phrase should call Typetexp.emit_external_warnings.structure, like Typemod.type_implementation and Typemod.type_interface do.

@vicuna

This comment has been minimized.

Copy link
Author

commented Dec 10, 2015

Comment author: @diml

Indeed, I committed the fix in trunk (87f92ab)

@vicuna

This comment has been minimized.

Copy link
Author

commented Dec 10, 2015

Comment author: @diml

Thinking more about this, using an AST mapper here is not perfect as you can't disable the warning with [@@@ocaml.warning "-22"].

@vicuna

This comment has been minimized.

Copy link
Author

commented Dec 10, 2015

Comment author: @alainfrisch

using an AST mapper here is not perfect as you can't disable the warning with [@@@ocaml.warning "-22"].

Indeed, and here is what the comment in the code says:

let emit_external_warnings =
  (* Note: this is run as a preliminary pass when type-checking an
     interface or implementation.  This allows to cover all kinds of
     attributes, but the drawback is that it doesn't take local
     configuration of warnings (with '@@warning'/'@@warnerror'
     attributes) into account.  We should rather check for
     'ppwarning' attributes during the actual type-checking, making
     sure to cover all contexts (easier and more ugly alternative:
     duplicate here the logic which control warnings locally). *)
...

@vicuna vicuna closed this Feb 16, 2017

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.