Skip to content

Commit

Permalink
Merge branch 'devel' into mir-type-ir
Browse files Browse the repository at this point in the history
  • Loading branch information
zerbina committed Jul 16, 2024
2 parents 5d04359 + d69d651 commit a8aed6a
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 4 deletions.
94 changes: 94 additions & 0 deletions .github/changelog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"categories": [
{
"title": "## 🚀 Features",
"labels": ["enhancement"],
"categories": [
{
"title": "### Compiler",
"labels": ["enhancement"],
"exhaustive": true,
"rules": [
{
"on_property": "labels",
"pattern": "compiler.*"
}
]
},
{
"title": "### Standard Library",
"labels": ["enhancement", "stdlib"],
"exhaustive": true
},
{
"title": "### Tooling",
"labels": ["enhancement", "tools"],
"exhaustive": true
}
]
},
{
"title": "## 🐛 Fixes",
"labels": ["bug"],
"categories": [
{
"title": "### Compiler",
"labels": ["bug"],
"exhaustive": true,
"rules": [
{
"on_property": "labels",
"pattern": "compiler.*"
}
]
},
{
"title": "### Standard Library",
"labels": ["bug", "stdlib"],
"exhaustive": true
},
{
"title": "### Tooling",
"labels": ["bug", "tool"],
"exhaustive": true
}
]
},
{
"title": "## 🔧 Refactorings",
"labels": ["refactor", "simplification"],
"categories": [
{
"title": "### Compiler",
"labels": ["refactor", "simplification"],
"exhaustive_rules": true,
"rules": [
{
"on_property": "labels",
"pattern": "compiler.*"
}
]
},
{
"title": "### Standard Library",
"labels": ["refactor", "stdlib"],
"exhaustive": true
},
{
"title": "### Tooling",
"labels": ["refactor", "tool"],
"exhaustive": true
}
]
},
{
"title": "## 💬 Other",
"labels": []
}
],
"template": "# What's Changed\n\n#{{CHANGELOG}}\n\n**Full Changelog**: #{{RELEASE_DIFF}}",
"empty_template": "**Full Changelog**: #{{RELEASE_DIFF}}",
"pr_template": "* #{{TITLE}} by @#{{AUTHOR}} in #{{URL}}",
"sort": "DSC",
"base_branches": ["devel"]
}
23 changes: 21 additions & 2 deletions .github/workflows/publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ jobs:
url: ${{ steps.release.outputs.url }}

steps:
# Repository required for changelog builder
- uses: actions/checkout@v4
with:
fetch-depth: 0
sparse-checkout: |
.github
- name: Obtain latest successful run id
id: finder
run: |
Expand Down Expand Up @@ -103,5 +110,17 @@ jobs:
tag_name: ${{ steps.release-files.outputs.version }}
fail_on_unmatched_files: true
target_commitish: ${{ github.event.after }}
body: |
Continuous delivery for commit ${{ github.event.after }}

- id: changelog
name: Create release changelog
uses: mikepenz/release-changelog-builder-action@v5.0.0-a04
with:
configuration: ".github/changelog.json"
toTag: ${{ steps.release-files.outputs.version }}
failOnError: true

- name: Push changelog
uses: softprops/action-gh-release@v2.0.6
with:
tag_name: ${{ steps.release-files.outputs.version }}
body: ${{ steps.changelog.outputs.changelog }}
81 changes: 81 additions & 0 deletions .github/workflows/slash-command-generate-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: /generate-changelog handler

on:
repository_dispatch:
types: [generate-changelog-command]

permissions:
pull-requests: write

concurrency: generate-changelog-handler-${{ github.event.client_payload.pull_request.node_id || github.run_id }}

jobs:
changelog:
if: github.event.client_payload.pull_request != null
name: Generate changelog and comment

runs-on: ubuntu-latest
env:
PR: ${{ github.event.client_payload.pull_request.number }}
steps:
- if: github.event.client_payload.pull_request.merge_commit_sha == null
name: Report "No merge HEAD" found
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ env.PR }}
body: |
Could not generate changelog using this PR as no GitHub merge commits are available.
This could be due to the PR being recently opened or there is a merge conflict. Please
try again after a few minutes.
- if: github.event.client_payload.pull_request.merge_commit_sha == null
name: Fail due to "No merge HEAD"
run: |
echo "::error::No merge HEAD found for PR #$PR"
exit 1
- name: "Checkout merge head for #${{ env.PR }}"
uses: actions/checkout@v4
with:
ref: ${{ github.event.client_payload.pull_request.merge_commit_sha }}
sparse-checkout: |
.github
- id: changelog
name: Create changelog
uses: mikepenz/release-changelog-builder-action@v5.0.0-a04
with:
configuration: ".github/changelog.json"
fromTag: ${{ github.event.client_payload.slash_command.args.named.from || '' }}
toTag: ${{ github.event.client_payload.slash_command.args.named.to || '' }}
ignorePreReleases: ${{ github.event.client_payload.slash_command.args.named.no_prerelease || false }}

- if: steps.changelog.outputs.failed == 'true'
name: Report failure
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ env.PR }}
body: |
Error occurred while generating changelog using this PR.
See run log at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}.
- if: steps.changelog.outputs.failed == 'true'
name: Fail due to changelog
run: |
echo "::error::Error occurred while generating changelog using PR #$PR"
exit 1
- name: Comment with changelog
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ env.PR }}
body: |
Changelog requested by: @${{ github.event.client_payload.github.payload.comment.user.login }}
Generated between ${{ steps.changelog.outputs.fromTag }} to ${{ steps.changelog.outputs.toTag }} using configuration provided by this PR.
---
${{ steps.changelog.outputs.changelog }}
1 change: 1 addition & 0 deletions .github/workflows/slash-commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ jobs:
reaction-token: ${{ steps.token.outputs.token }}
commands: |
merge
generate-changelog
issue-type: pull-request
permission: write
22 changes: 20 additions & 2 deletions compiler/ic/cbackend.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

import
std/[
packedsets, algorithm
algorithm,
packedsets,
tables
],
compiler/ast/[
ast,
Expand Down Expand Up @@ -42,7 +44,8 @@ import
rodfiles
],
compiler/sem/[
modulelowering
modulelowering,
sighashes
]

import compiler/backend/cbackend as cbackend2
Expand Down Expand Up @@ -195,6 +198,21 @@ proc generateCode*(g: ModuleGraph) =
mlist.modulesClosed.add(pos)
break

# fill the table of canonical types; hook injection needs it during its
# lookup
for e in attachedAsgn..attachedTrace:
for item, sym in g.attachedOps[e].mpairs:
# retrieving the attached-to type from the symbol is easier than
# trying to map `item` to a PType
let resolved = loadSymFromId(g.config, g.cache, g.packed, sym.id.module,
sym.id.packed)
if resolved.typ != nil:
# XXX: for an unknown reason, some symbols don't have a type
let t = resolved.typ[1].skipTypes({tyVar})
# ignore types that don't have real type-bound operators
if tfHasAsgn in t.flags and t.kind notin {tyDistinct, tyObject}:
discard g.canonTypes.mgetOrPut(hashType(t, {CoDistinct, CoType}), t)

# Fourth pass: Generate the code:
cbackend2.generateCode(g, backend, mlist)
g.backend = backend
Expand Down
23 changes: 23 additions & 0 deletions tests/ic/tcanonical_types.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
discard """
description: '''
Regression test for compiler crash due to missing hook attachments. The
test is contrived and depends on compiler implementation details.
'''
"""

proc f1(x: ref int): ref int =
# the assignment requires the =copy hook. `f1` is processed by hook lifting
# first, so the lifetime hooks are bound to the result variable's ``ref int``
# instance
result = x

proc f2(x: ref int) =
discard

# use `f2` first so that its ``ref int`` instance is registered with the
# environment
f2(nil)
# then use `f1`. It's ``ref int`` instance is mapped to that of `f2`, and
# since `f2`'s ``ref int`` *instance* has no hook attached, missing canonical
# type mappings result in a crash (as no hook can be found)
discard f1(nil)

0 comments on commit a8aed6a

Please sign in to comment.