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

feat: purity computer #784

Merged
merged 12 commits into from
Nov 20, 2023
Merged

feat: purity computer #784

merged 12 commits into from
Nov 20, 2023

Conversation

lars-reimann
Copy link
Member

@lars-reimann lars-reimann commented Nov 20, 2023

Summary of Changes

Add a new service that infers whether a call or callable is pure or has side effects.

# Conflicts:
#	packages/safe-ds-lang/src/language/flow/safe-ds-call-graph-computer.ts
#	packages/safe-ds-lang/src/language/validation/purity.ts
#	packages/safe-ds-lang/src/language/validation/safe-ds-validator.ts
#	packages/safe-ds-lang/tests/resources/validation/purity/pure parameter must have callable type/main.sdstest
# Conflicts:
#	packages/safe-ds-lang/tests/language/flow/safe-ds-call-graph-computer.test.ts
Copy link

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ REPOSITORY git_diff yes no 0.07s
✅ TYPESCRIPT eslint 10 0 0 4.36s
✅ TYPESCRIPT prettier 10 0 0 1.19s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

Copy link

codecov bot commented Nov 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f7eabd8) 100.00% compared to head (f9733ad) 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #784    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           82        83     +1     
  Lines        12549     12738   +189     
  Branches      2637      2682    +45     
==========================================
+ Hits         12549     12738   +189     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lars-reimann
Copy link
Member Author

lars-reimann commented Nov 20, 2023

@WinPlay02 services.purity.PurityComputer adds the methods you need to implement the remainder of #542. Please let me know if something is missing.

@lars-reimann lars-reimann marked this pull request as ready for review November 20, 2023 15:05
@lars-reimann lars-reimann merged commit b09bb3a into main Nov 20, 2023
8 checks passed
@lars-reimann lars-reimann deleted the purity-computer branch November 20, 2023 15:05
lars-reimann pushed a commit that referenced this pull request Nov 22, 2023
## [0.4.0](v0.3.0...v0.4.0) (2023-11-22)

### Features

* add endless recursion as an impurity reason ([#788](#788)) ([98acdde](98acdde))
* call graph computer (without closures) ([#782](#782)) ([34bf182](34bf182))
* check types of constant parameters ([#775](#775)) ([0a02850](0a02850)), closes [#668](#668)
* check whether purity of callable parameters of functions is set properly ([#777](#777)) ([f8fd907](f8fd907)), closes [#732](#732)
* compute purity/side effects for expressions ([#785](#785)) ([9ed1c08](9ed1c08)), closes [#15](#15)
* compute types of parameters of lambdas that are passed as default value ([#780](#780)) ([01a5c03](01a5c03))
* error if call leads to infinite recursion ([#783](#783)) ([f7eabd8](f7eabd8)), closes [#667](#667)
* error if impure callable is passed to pure parameter ([#792](#792)) ([5536a4a](5536a4a)), closes [#730](#730)
* error if parameter name in impurity reason is invalid ([#772](#772)) ([faa2012](faa2012)), closes [#741](#741)
* error if purity of functions is not specified ([#768](#768)) ([a15b0af](a15b0af)), closes [#731](#731)
* filter statements without effect for code generation ([#786](#786)) ([cd4f2c1](cd4f2c1)), closes [#542](#542)
* improve location of warning about duplicate annotation target ([#771](#771)) ([87d2a48](87d2a48))
* info if `@Pure` annotation is called on parameter of pure function ([#778](#778)) ([c15c70e](c15c70e))
* purity computer ([#784](#784)) ([b09bb3a](b09bb3a))
* remove type parameters from enum variants ([#767](#767)) ([cb6556a](cb6556a)), closes [#766](#766)
* short-circuit `and`, `or`, and `?:` if RHS has no side effects ([#789](#789)) ([9d9f4b7](9d9f4b7)), closes [#15](#15)
* streamline purity information ([#779](#779)) ([75a9e5b](75a9e5b))
* stricter definition of `const` parameters ([#776](#776)) ([73a0d4e](73a0d4e))
* update snippets for functions and methods ([#769](#769)) ([061d3b1](061d3b1))
* validate impurity reasons of overriding methods ([#774](#774)) ([71fc5bd](71fc5bd)), closes [#665](#665)
* warn about duplicate impurity reasons ([#773](#773)) ([8344356](8344356)), closes [#733](#733)
* warn if statement has no effect ([#787](#787)) ([6f45dc4](6f45dc4)), closes [#664](#664)

### Bug Fixes

* signature help for optional parameters ([#793](#793)) ([fd88ce8](fd88ce8)), closes [#791](#791)
* wrong detection of useless statements that call parameters/unknown callables ([#790](#790)) ([a49b4b3](a49b4b3))
* wrong`"assignment/nothing-assigned"` error if RHS calls expression lambda ([#781](#781)) ([b909cb8](b909cb8))
@lars-reimann
Copy link
Member Author

🎉 This PR is included in version 0.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lars-reimann lars-reimann added the released Included in a release label Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Included in a release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant