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

STAN-0206 doesn't go away after enabling -XStrictData #392

Closed
codygman opened this issue Sep 22, 2020 · 9 comments
Closed

STAN-0206 doesn't go away after enabling -XStrictData #392

codygman opened this issue Sep 22, 2020 · 9 comments
Labels
question Further information is requested

Comments

@codygman
Copy link

Posting this for someone else, I'll try to add more detail (or get them too) and reproduce if I can later.

@goolord
Copy link

goolord commented Sep 22, 2020

minimal example https://github.com/goolord/stan-stricdata-minimal

nothing special required to reproduce this really, the error doesn't go away whether it's a language pragma, in the default-extensions stanza of the cabal file, or otherwise

@chshersh
Copy link
Contributor

@codygman @goolord Can you provide more info on Stan version you are using, how did you build the project, created the HIE files and how are you running Stan?

I just tried running the following on the example repository using the latest version of Stan from master:

cabal build
stan

And everything works as expected, i.e. I don't see any observations in the terminal output.

@chshersh chshersh added the question Further information is requested label Sep 22, 2020
@goolord
Copy link

goolord commented Sep 22, 2020

\Stan v0.0.1.0
 ➤ Git revision: 04d5a192cebb8e63b8704bdd2a8afe5b2d1c3493
 ➤ Commit date:  Tue Sep 15 16:11:42 2020 +0000
 ➤ GHC version:  8.8

built w/ cabal from master

@vrom911
Copy link
Member

vrom911 commented Sep 23, 2020

@codygman @goolord This is not reproducible for me as well. I build the project with Cabal and the same Stan and GHC version. I am on Mac, and @chshersh checked on Linux.

Stan does not produce any observations, and also is able to recognize the StrictData extension.

           Stan's Summary:
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┓
┃ Analysed modules             ┃ 1      ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Analysed Lines of Code       ┃ 11     ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Total Haskell2010 extensions ┃ 1      ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Total SafeHaskell extensions ┃ 0      ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Total checked inspections    ┃ 44     ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Total found observations     ┃ 0      ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Total ignored observations   ┃ 0      ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Project health               ┃ 100%   ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━┛

Could you provide some details of any specific tools or features you are using to build/run stan-stricdata-minimal?

@vrom911
Copy link
Member

vrom911 commented Sep 23, 2020

Moreover, we have a lot of tests on this particular inspection, so we do check that this inspection actually works:

strictFieldsSpec :: Analysis -> Spec
strictFieldsSpec analysis = describe "STAN-0206: Strict data type fields" $ do
describe "Without extensions" $ do
let checkObservation = observationAssert ["AntiPattern", "Stan0206"] analysis
let noObservation = noObservationAssert ["AntiPattern", "Stan0206"] analysis
it "Doesn't trigger on strict field" $
noObservation AntiPattern.stan0206 7
it "Finds simple lazy field" $
checkObservation AntiPattern.stan0206 8 7 25
it "Finds polymorphic lazy field" $
checkObservation AntiPattern.stan0206 9 7 23
it "Doesn't trigger on plain newtype" $
noObservation AntiPattern.stan0206 12
it "Doesn't trigger on a record newtype" $
noObservation AntiPattern.stan0206 14
it "Doesn't trigger on strict sum type field among many fields" $
noObservation AntiPattern.stan0206 19
it "Finds lazy field in a sum type constructor with multiple fields" $
checkObservation AntiPattern.stan0206 20 9 12
it "Doesn't trigger on a single strict sum type field" $
noObservation AntiPattern.stan0206 21
it "Finds single lazy field in a sum type with multiple constructors" $
checkObservation AntiPattern.stan0206 22 11 15
it "Doesn't trigger on forall wo constraint with 1 var" $
noObservation AntiPattern.stan0206 25
it "Finds single lazy field after forall wo constraint with 1 var" $
checkObservation AntiPattern.stan0206 26 16 17
it "Doesn't trigger on forall wo constraint with 2 var" $
noObservation AntiPattern.stan0206 27
it "Finds single lazy field after forall wo constraint with 2 var" $
checkObservation AntiPattern.stan0206 28 17 18
it "Doesn't trigger on strict field after forall wo constraint with 2 var" $
noObservation AntiPattern.stan0206 29
it "Doesn't trigger on forall constraint with 1 var" $
noObservation AntiPattern.stan0206 30
it "Finds single lazy field after forall constraint with 1 var" $
checkObservation AntiPattern.stan0206 31 17 18
it "Doesn't trigger on forall constraint with 2 var" $
noObservation AntiPattern.stan0206 32
it "Finds single lazy field after forall constraint with 2 var" $
checkObservation AntiPattern.stan0206 33 17 18
it "Doesn't trigger on strict field after forall constraint with 2 var" $
noObservation AntiPattern.stan0206 34
it "Doesn't trigger on forall constraint on record type" $
noObservation AntiPattern.stan0206 36
it "Findsa lazy Int field after forall constraint on record type" $
checkObservation AntiPattern.stan0206 38 7 19
it "Finds a lazy constrainted field after forall on record type" $
checkObservation AntiPattern.stan0206 39 7 17
describe "With the 'StrictData' extension" $ do
let noObservation = noObservationAssert ["AntiPattern", "Stan0206Extensions"] analysis
it "Doesn't trigger on a simple record field" $
noObservation AntiPattern.stan0206 9
it "Doesn't trigger on explicitly lazy field" $
noObservation AntiPattern.stan0206 10
it "Doesn't trigger on plain data type" $
noObservation AntiPattern.stan0206 13

@codygman
Copy link
Author

codygman commented Sep 23, 2020

I just tried reproducing from NixOS and couldn't.... might be something machine specific for @goolord. We'll have to take a look.

Reproduction attempt
[cody@nixos:/tmp/stan-stricdata-minimal]$ PAGER=cat git log --oneline
be50c35 (HEAD -> master, origin/master, origin/HEAD) first commit

[cody@nixos:/tmp/stan-stricdata-minimal]$ nix-shell -p pkgs.haskell.compiler.ghc883 --run "cabal build"
Up to date
[cody@nixos:/tmp/stan-stricdata-minimal]$ ~/code/stan/.stack-work/install/x86_64-linux-nix/21146bec5e0de701f60e46f363fd96007d3477ee1dd9fe80145db1c049dace60/8.8.3/bin/stan report
  ⓘ Checking environment variables and CLI arguments for default configurations file usage...
    Fiasco:
      * [Error  ] No STAN_USE_DEFAULT_CONFIG Env Variable is set
      * [Error  ] No CLI option specified for no-default

  ⓘ The following Configurations are used:

    Result:
   
    With the following warnings:
      * [Warning] TOML Configurations file doesn't exist: /tmp/stan-stricdata-minimal/.stan.toml
      * [Warning] TOML Configurations file doesn't exist: /home/cody/.stan.toml
      * [Warning] No CLI option specified for: checks
      * [Warning] configChecks is set through the source: Default
      * [Warning] TOML Configurations file doesn't exist: /tmp/stan-stricdata-minimal/.stan.toml
      * [Warning] TOML Configurations file doesn't exist: /home/cody/.stan.toml
      * [Warning] No CLI option specified for: remove
      * [Warning] configRemoved is set through the source: Default
      * [Warning] TOML Configurations file doesn't exist: /tmp/stan-stricdata-minimal/.stan.toml
      * [Warning] TOML Configurations file doesn't exist: /home/cody/.stan.toml
      * [Warning] No CLI option specified for: ignore
      * [Warning] configIgnored is set through the source: Default

  ⓘ Using the following .cabal file: /tmp/stan-stricdata-minimal/stan-stricdata-minimal.cabal

  ✔ All clean! Stan did not find any observations at the moment.

           Stan's Summary:
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┓
┃ Analysed modules             ┃ 1      ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Analysed Lines of Code       ┃ 11     ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Total Haskell2010 extensions ┃ 1      ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Total SafeHaskell extensions ┃ 0      ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Total checked inspections    ┃ 44     ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Total found observations     ┃ 0      ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Total ignored observations   ┃ 0      ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━┫
┃ Project health               ┃ 100%   ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━┛

  ⓘ Report is generated here -> stan.html

@goolord
Copy link

goolord commented Sep 23, 2020

I deleted the .hie directory and I can't reproduce this anymore. I don't know what was causing this, it persisted through rebuilds yesterday, but I think it's safe to just close this. Thanks for looking into it 👍

@vrom911
Copy link
Member

vrom911 commented Sep 23, 2020

No worries! Let us know if you see some issues again 🙂

@srid
Copy link

srid commented Dec 17, 2024

I can reliably reproduce this. Here's a repro using Nix:

srid/haskell-template#147

EDIT: In this case, fix was srid/haskell-flake#386

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants