Skip to content

Elixir: Multi-clause functions and interpolated strings#614

Merged
dimitris-m merged 2 commits intomainfrom
mpir/elixir-update
Mar 17, 2026
Merged

Elixir: Multi-clause functions and interpolated strings#614
dimitris-m merged 2 commits intomainfrom
mpir/elixir-update

Conversation

@maciejpirog
Copy link
Copy Markdown
Contributor

@maciejpirog maciejpirog commented Mar 16, 2026

This PR fixes two things:

Multi-clause functions

Functions can be defined via multiple clauses, like:

def factorial(0) do
    1
end
def factorial(n) do
    n * factorial(n - 1)
end

Before: these were understood as two separate functions with the same name (+ when clauses were not supported).
After: they are the same function (+when clauses work now).

Note that the mechanism works slightly differently than in Clojure, because in Elixir two functions with the same name but different arities are actually two functions. For example, the following code defines two functions:

def foo(0), do: something()
def foo(x), do: something()
def foo(0, y), do: something()
def foo(1, y), do: something()
def foo(x, y), do: something()

Interpolated strings

They didn't work before, they work now

| None -> S (D (FuncDef [ clause ])) :: group_func_clauses rest
| Some key ->
let rec take_matching acc = function
| S (D (FuncDef [ c ])) :: tl when func_clause_key c = Some key ->
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polymorphic equality which I guess is unavoidable as long as the key is defined as is, but maybe if it was a record with derived equality ....

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I introduced a separate type with (hand-defined, but not polymorphic) equality

@dimitris-m dimitris-m merged commit 08cdae8 into main Mar 17, 2026
11 of 12 checks passed
@dimitris-m dimitris-m deleted the mpir/elixir-update branch March 17, 2026 15:18
@maciejpirog maciejpirog mentioned this pull request Mar 17, 2026
@maciejpirog
Copy link
Copy Markdown
Contributor Author

Closes #602

tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Mar 25, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [opengrep/opengrep](https://github.com/opengrep/opengrep) | patch | `v1.16.4` → `v1.16.5` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>opengrep/opengrep (opengrep/opengrep)</summary>

### [`v1.16.5`](https://github.com/opengrep/opengrep/releases/tag/v1.16.5): Opengrep 1.16.5

[Compare Source](opengrep/opengrep@v1.16.4...v1.16.5)

#### Improvements

- Improvements in recognizing language-specific built-in functions in intrafile tainting by [@&#8203;corneliuhoffman](https://github.com/corneliuhoffman) in [#&#8203;617](opengrep/opengrep#617)
- Elixir: Support for multi-clause functions and interpolated strings by [@&#8203;maciejpirog](https://github.com/maciejpirog) in [#&#8203;614](opengrep/opengrep#614)

**Full Changelog**: <opengrep/opengrep@v1.16.4...v1.16.5>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My44OS42IiwidXBkYXRlZEluVmVyIjoiNDMuODkuNiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6OnBhdGNoIl19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants