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

Fix warning for Elixir 1.18 #36

Merged
merged 8 commits into from
Dec 20, 2024
Merged

Fix warning for Elixir 1.18 #36

merged 8 commits into from
Dec 20, 2024

Conversation

jackalcooper
Copy link
Contributor

@jackalcooper jackalcooper commented Dec 20, 2024

Summary by CodeRabbit

  • New Features

    • Expanded Elixir CI workflow to include version 1.18.0.
    • Added steps to check formatting of Elixir code in main and example directories.
  • Bug Fixes

    • Improved error handling for unimplemented NIFs.
  • Refactor

    • Restructured the use Kinda.CodeGen directive in the KindaExample.NIF module for clarity.
    • Enhanced the structure of NIF declarations and macro usage in the Kinda.CodeGen module.
  • Chores

    • Updated version number of the Kinda application from 0.9.4-dev to 0.9.5-dev.

Copy link

coderabbitai bot commented Dec 20, 2024

Walkthrough

The pull request introduces updates to the Elixir CI workflow and the Kinda library's code generation mechanism. The changes focus on expanding the CI matrix to include a new Elixir version, adding code formatting checks, and refining the NIF (Native Implemented Function) code generation process. The modifications enhance the project's testing coverage and improve the macro-based code generation approach for native interfaces.

Changes

File Change Summary
.github/workflows/elixir.yml - Added Elixir version 1.18.0 to job matrix
- Added exclusion rule for otp: "24.2" and elixir: "1.18.0"
- Introduced two steps to check Elixir code formatting
lib/kinda_codegen.ex - Modified __using__/1 macro to destructure nif_ast/4 result
- Updated nif_ast/4 function handling of NIF declarations
- Changed error handling for unimplemented NIFs
kinda_example/lib/kinda_example_nif.ex - Restructured use Kinda.CodeGen declaration as module attribute @nifs
mix.exs - Updated version from "0.9.4-dev" to "0.9.5-dev"

Sequence Diagram

sequenceDiagram
    participant Workflow as CI Workflow
    participant CodeGen as Kinda.CodeGen
    participant NIF as NIF Module

    Workflow->>CodeGen: Generate NIF AST
    CodeGen-->>NIF: Evaluate AST
    NIF-->>CodeGen: Return Module and Function
    CodeGen-->>Workflow: Complete NIF Generation
Loading

Poem

🐰 Elixir's dance, a matrix so bright,
Workflows twirl with formatting's might,
NIFs leap through macros' embrace,
Code generation's elegant grace,
Rabbit's code hops with pure delight! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c18a20 and d7c5981.

⛔ Files ignored due to path filters (1)
  • mix.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • mix.exs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • mix.exs

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
lib/kinda_codegen.ex (2)

Line range hint 32-47: Ensure correct struct-based pattern matching in NIFDecl.
It’s good practice to verify that the %NIFDecl{} struct includes all required fields for correct pattern matching. If future fields are introduced to the struct, their default handling or matching must be updated in this case block.


71-77: NIF error handling improvements.
Returning :erlang.nif_error(:not_loaded) ensures a graceful failure in production. However, it might be beneficial to log or track these errors in a more robust manner.

kinda_example/lib/kinda_exmaple_nif.ex (1)

2-5: Module attribute used for macro invocation.
Declaring “@nifs use Kinda.CodeGen…” is a stylistic choice that can improve readability by centralizing the arguments, but be mindful that it might confuse new contributors expecting a standard “use” at the top level. Consider adding a brief comment explaining the reason for using a module attribute if more contributors are expected to work on this code.

.github/workflows/elixir.yml (1)

26-29: Add matrix exclusion rationale.
Excluding the “otp: 24.2” and “elixir: 1.18.0” combination is valid if known incompatibilities exist. Documenting the reason for this exclusion can help future maintainers.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 04ae659 and 13efa4f.

📒 Files selected for processing (3)
  • .github/workflows/elixir.yml (1 hunks)
  • kinda_example/lib/kinda_exmaple_nif.ex (1 hunks)
  • lib/kinda_codegen.ex (4 hunks)
🔇 Additional comments (3)
lib/kinda_codegen.ex (3)

13-14: Confirm consistent usage of return tuple.
These two lines rely on tuple-destructuring the result of nif_ast (i.e., {ast, mf}). Ensure all upstream references to the AST and the mf align with this new approach so calling code doesn't rely on the previously piped approach.


30-31: Double-check potential duplication of NIF declarations.
Here, nifs are concatenated with extra_kind_nifs. If both contain overlapping or identical declarations, it may lead to conflicts or unexpected behavior. Consider deduplicating or verifying uniqueness before concatenation.


57-67: Conditionally define a wrapper function.
By checking if nif_name != wrapper_name, a second function definition is introduced only when needed. This is good, but watch out for edge cases involving name collisions (e.g., if wrapper_name is changed dynamically). A test covering that scenario would be beneficial.

@jackalcooper jackalcooper merged commit 509c88e into main Dec 20, 2024
5 checks passed
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.

1 participant