Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 1, 2025

Overview

This PR implements the ability to pass failure exit codes to failed blocks via parameters, matching the existing functionality of then blocks. This addresses issue #XXX.

Problem

Previously, when handling failures in Amber, developers had to manually capture the exit code in a temporary variable before running any additional commands in the failed block:

$ command $ failed {
    let error = status
    trust $ cleanup_command $
    echo "Exit code: {error}"
}

This was necessary because running additional commands inside the failed block would overwrite the status variable, losing the original error code.

Solution

The failed block now supports an optional parameter syntax, similar to the then block:

$ command $ failed(error) {
    trust $ cleanup_command $
    echo "Exit code: {error}"
}

The parameter captures the exit code immediately and keeps it isolated from subsequent command executions.

Implementation Details

  • Modified: src/modules/condition/failed.rs

    • Added param_name and param_global_id fields to the Failed struct
    • Enhanced parser to handle optional (parameter_name) syntax
    • Updated translator to assign exit code to parameter variable when provided
    • Added validation for empty parameter names
  • Backward Compatibility: All existing code without parameters continues to work exactly as before

  • Test Coverage: Added 3 new test cases

    • Basic parameter functionality
    • Parameter isolation verification
    • Error handling for invalid syntax

Examples

Basic usage

silent $ nonexistent_command $ failed(code) {
    echo "Command failed with exit code: {code}"
}

Parameter isolation

silent $ false $ failed(error) {
    trust $ ls > /dev/null $  // This changes 'status'
    echo "Original error: {error}"  // But parameter preserves original code
    echo "Current status: {status}"
}

Testing

  • ✅ All 364 tests pass
  • ✅ Generated Bash code verified for correctness
  • ✅ Backward compatibility confirmed
  • ✅ Consistent with then block behavior

Benefits

  • Cleaner code: Eliminates need for temporary variables
  • Explicit intent: Parameter makes error handling more readable
  • Preserves context: Original exit code remains accessible regardless of subsequent operations
  • API consistency: Matches the existing then block pattern
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature] Ability to pass failure exit code to the failed block</issue_title>
<issue_description>Is your feature request related to a problem? Please describe.
Currently we have failed block that runs when a failure has to be handled. We already expose then block which exposes error code under a variable.

$ ... $ then(exit_code) {
  echo exit_code
}

Add ability to do the same for failure block.

Describe the solution you'd like
Ability to run this block of code like this

$ ... $ failed(code) {
  echo code
}

Additional context
This is important because in the handling block we may run multiple other failing expression, thus introducing a necessity to create a failed variable.

// Before
$ ... $ failed {
  let error = status
  trust $ ... $
  echo "Exit code: {error}"
}

// After
$ ... $ failed(error) {
  trust $ ... $
  echo "Exit code: {error}"
}

</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #801

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>
Copilot AI changed the title [WIP] [Feature] Ability to pass failure exit code to the failed block Add parameter support to failed block for capturing exit codes Oct 1, 2025
Copilot AI requested a review from Ph0enixKM October 1, 2025 10:57
Copilot finished work on behalf of Ph0enixKM October 1, 2025 10:57
@Ph0enixKM Ph0enixKM marked this pull request as ready for review October 1, 2025 12:30
@Ph0enixKM Ph0enixKM merged commit 82e9280 into staging Oct 2, 2025
28 checks passed
@Ph0enixKM Ph0enixKM deleted the copilot/fix-d6f1e8c5-c73a-4469-ac88-61a2406158db branch October 2, 2025 13:54
Ph0enixKM added a commit that referenced this pull request Nov 28, 2025
* [docs] Use version instead of master when linking (#649)

* Write docs to standard output (#655)

* Write docs to stdout with target "-".

* Minor refactoring.

* Make Clippy happy.

* Unindent main block (#654)

* Unindent code in main block.

* Cap indentation level at zero.

* Add TODO comment as requested.

* Improve docs usage links (#653)

* Implement failability as function property instead of type (#642)

Removes the Failable type. Implements failability as a property of a function, instead.

---------

Co-authored-by: hdwalters <huw.walters@gmail.com>
Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* fix: validate function argument names for duplicates (#680)

* feat(install): removed from repo (#644)

* replace_regex: remove bash word boundary when detecting gnused (#686)

* New translation modules architecture (#678)

* feat: initial commit

* fix: validity tests

* fix: some of the stdlib errors

* fix: some tests

* fix: stdlib tests

* fix: additional error

* fix: cargo clippy

* fix: wrong quoting

* fix: wrong init value

* fix: block rendering

* feat: improve block formatting

* fix: shellcheck issues

* feat: add more tests

* fix: shellcheck issues

* fix: clippy error

* feat: add ternary tests

* fix: escaping of slices

* impl From<String> for CommentFragment

* simplify path for use

* refactor match for readability

Co-authored-by: Huw Walters <huw.walters@gmail.com>

* refactor &*self.index -> self.index.as_ref()

* add trailing comma to match block

* rigidly match all requirements to be 1 1 0

* remove a redundant blank line

* simplify echoing the array

* reword unreachable code

* refactor constructor to give every function its own line

* refactor: render -> to_string

* fix: trailing commas

* refactor: rename fragment structures

* refactor: symbols and block fn name

* refactor: add context to text escaped regular character test

* refactor: remove padding in doc comments

* fix: comment and compound

* refactor: remove unnecessary files

* refactor: compount -> list

* refactor: set_quoted -> with_quotes

* refactor: iter loop

* refactor: fragments(raw:) -> raw_fragment()

* refactor: formatting

* refactor: improve readability

* refactor: variable

* refactor: finalize addressing concerns

* fix: clippy errors

---------

Co-authored-by: b1ek <me@blek.codes>
Co-authored-by: Huw Walters <huw.walters@gmail.com>

* Added Git version at build-time (#685)

* test: Use the bash container and a matrix strategy for bash versions (#616)

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>
Co-authored-by: Daniele Scasciafratte <mte90net@gmail.com>
Co-authored-by: b1ek <me@blek.codes>

* Replace Amber text interpolation with Bash parameter expansion (#592)

Co-authored-by: Huw Walters <huw.walters@gmail.com>
Co-authored-by: Daniele Scasciafratte <mte90net@gmail.com>

* fix: base_base_image -> base_bash_image (#704)

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* Add Variable Statement Translation Fragment (#698)

* run workflows on main and staging (#705)

* vscode debug profile (#692)

* Add function that returns installed bash version (#703)

* Fix CI/CD regarding bash_version PR (#708)

* feat: add bash version comparison function

* feat: add star expansion to var expr

* feat: add lexical comparison

* feat: add array comparison operator for numerical comparisons

* feat: add lexical comparison operators

* feat: add function that returns current bash version

* fix: clippy

* refactor: remove leftover note

* refactor: improve readability of version comparison

* feat: update error messages

* refactor: componentize parts of lexical ordering function

* feat: add underscord before 'i' variable

* feat: rename 'star expansion' to 'array to string'

* refactor: rename variable

* fix: improve logic of array comparison

* feat: add tests for different sizes

* feat: add tests for different sizes - text

* fix: operators

* fix: bad tests

* fix: eq fragment unused

* feat: pluralize

* fix: CI/CD

* Fix CI pipeline for old Bash versions and add macOS support. (#701)

* feat: add macOS CI testing workflow

* fix: std text replace not failing

* fix: make replace compatible with bash 4.2

* fix: base_base_image -> base_bash_image

* doc: minor styling

* fix: replace function

* fix: regex basic test

* fix: array_extract_at test

* fix: date posix test

* fix: Update condition to filter Bash 4.4 or later (#709)

* fix: Use the approch for Bash 4.3 or newer

* Update src/std/text.ab

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* Update text.ab

---------

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* Feat: Improve date library (#712)

* fix: date library

* Update src/std/date.ab

Co-authored-by: Hubert Jabłoński <hubik080@gmail.com>

* Update src/std/date.ab

Co-authored-by: Hubert Jabłoński <hubik080@gmail.com>

* fix: comments

* feat: improve formatting of comments

* feat: describe what unix epoch format is expected

* fix: utc problem

---------

Co-authored-by: Daniele Scasciafratte <mte90net@gmail.com>
Co-authored-by: Hubert Jabłoński <hubik080@gmail.com>

* Introduce optimizer - remove unused variables (#706)

* feat: add scaffolding

* feat: simple optimizer

* feat: enable optimizer

* feat: add transitive dependency support for optimizer

* feat: remove unnecessary files

* feat: clippy linting errors

* feat: add support for detecting variable redeclaration and tracking conditional scopes

* fix: transitive variables in conditional blocks are also used

* refactor: add comments

* feat: handle redeclared variables in conditional blocks

* feat: add tests

* refactor: clippy linting

* feat: add test

* chore(test): fix bash_error_exit_code of macos runner (#710)

* fix: merge of subprocess with inner math resolution (#715)

* Fix clippy::uninlined_format_args (#722)

* docs: fix comment of UnOp group macro (#720)

* fix: Disable some GNU Sed only features (#717)

* fix: Disable GNU Sed only features

* Apply rewording suggestions from code review

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* chore(test): Shared test structure

* chore(test): Include busybox sed test

* Support BusyBox sed

* Apply suggestions from code review

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

---------

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* feat(std/fs): Create cross OS compatible mktemp function (#718)

* feat(std/fs): Create OSX compatible mktemp function

* feat: Handle possible failure of mktemp

* test: Use if chain

* Apply suggestions from code review

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

---------

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* [BUG] Bad escaping for a string with \$ sequence #593 (#594)

* fix: bad string escaping

* feat: remove unused function

* fix: bad variable interpolation

* feat: Add "absurd cast" warning when casting Text to Bool (#719)

* test: Add bash 5.3 matrix (#725)

* Remove mistakenly added code in fs.ab (#730)

* Add new `Int` type (#721)

* feat: add int type

* feat: add rest of the int functionality

* fix: clippy

* feat: make negation yield in case of parsing a number literal

* fix: validity tests

* feat: allow using Int with Num

* fix: exit builtin now only accepts int

* fix: grammar in error message

* feat: improve subset mechnism to also cover arrays

* fix: clippy

* fix: remove inner quotes from arithmetic fragment

* feat: add Type::Int where it's missing

* fix: code review

* feat: improve unreachables for eq and neq

* feat: add support for comparing [Num]

* feat: add tests and fix some bad behaviours

* feat: add int for shorthand

* fix: clippy

* fix: clippy

* feat: add ast comparison

* feat: add snapshot based AST testing

* Remove shfmt postprocessor support as it was rendered redundant (#735)

* Add warning for invalid escape sequences in string literals (#732)

* Initial plan

* Add warning for invalid escape sequences in string literals

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Add comprehensive tests for invalid escape sequence warnings

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix Clippy warning: use inline format args

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Refactor escape sequence validation to eliminate unnecessary conditional checks

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Simplify escape sequence validation by reducing if statement and eliminating duplicate function

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Simplify escape sequence validation and fix indentation as requested by reviewer

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Pass token by value to avoid unnecessary cloning as requested by reviewer

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix warning positioning to highlight the exact invalid character in escape sequences

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Revert token positioning changes to use simpler string token highlighting

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Remove unnecessary token cloning by using references in escape sequence validation

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* fix: highlight the correct section of the code

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>
Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* feat: Give auto deletion funtionality to temp_dir_create() (#726)

* feat: Give auto deletion funtionality to temp_dir_create()

* test: Use temp_dir_create function instead of direct command call

* Update fs_file_chmod.ab

* Update fs.ab

* feat: add trim

---------

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* chore(text.ab): Rename the parameters to source and search (#742)

* Add optimizer for ephemeral (intermediate) variables (#728)

* feat: add ephermal var optimizer

* fix: clean up

* feat: add tests

* fix: cargo clippy

* feat: improve ephemeral var optimizer

* faet: improve algorithm to be in O(n) time

* feat: remove new snapshots

* feat: add ephemeral tests

* ignore escaped newline in comments (#741)

* ignore escaped newline in comments

* feat: bump heraclitus

* feat: make validity tests to also test the STDERR

* fix: index out of bounds in other tests

---------

Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* feat: test for unused variables that are assigned to any subprocess (#746)

* Fix remove global variables in functions (#729)

* fix: global variables in functions

* fix: clippy

* fix: clippy

* feat: add test

* Loop iterator has to be Int (#752)

* feat: iterator is now Int

* feat: add tests

* Fix concurrency issue in input tests by using unique temporary files (#756)

* Initial plan

* Fix concurrency issue in input tests by using unique temporary files

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix import statement error handling for star (*) in closure with helpful message (#755)

* Initial plan

* Implement error handling for star in import closure with helpful message

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Refactor CLI tests to use internal API with inline logic for improved simplicity

* Initial plan

* Refactor CLI tests to use internal API instead of external binary

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix clippy warning: remove redundant field assignment in CLI tests

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Improve CLI tests readability with helper functions and add message count assertion

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Refactor CLI tests with assertSingleWarning function as requested

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Simplify CLI tests to use single warning pattern only as requested

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Inline helper function logic and simplify error handling with unwrap calls as requested

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Implement support for reverse range expressions (fixes #471) (#753)

* Initial plan

* Implement reverse range support with compile-time and runtime detection

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Refactor range translate method into smaller, more readable functions

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Rename variable to_raw to to for consistency with from variable

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>
Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* feat: improve escaping (#759)

* Add new and simpler release pipeline (#758)

* feat: add new and simpler release pipeline

* feat: remove cargo-dist

* feat: new installer

* feat: update installer script

* Update release.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Implement `while` loop feature for Amber language (#762)

* Initial plan

* Implement while loop feature with grammar, parsing, translation, and tests

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Address PR feedback: fix error handling, use += syntax, inline output comments, remove redundant test

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix clippy warning by using vec! macro directly instead of push pattern

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix: Unused variables optimizer removes variables also in case of shorthand expression (#763)

* fix: optimizer - unused variables

* feat: improve tests for optimizing

* Unify block parsing to support both single-line and multi-line blocks consistently (#765)

* Initial plan

* Implement unified block parsing for single-line and multi-line blocks

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Refactor Block parsing to handle unified syntax in parse() method as requested

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Refactor Block::parse() to use requested approach with token consumption pattern

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* feat: unified way to write blocks

* feat: update while loop

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>
Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* Implemented AMBER_HEADER and AMBER_FOOTER variables (#682)

* Implemented AMBER_HEADER and AMBER_FOOTER variables

* rewrite dynamic header & footer to be consistent with the rest of the codebase

* hardcode newlines after header & result

* feat: resolve conflicts

* feat: create gen_header and gen_footer functions

* remove debug calls

* feat: improve error message format

---------

Co-authored-by: blek! <me@blek.codes>
Co-authored-by: Daniele Scasciafratte <mte90net@gmail.com>
Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* Update standard library to use `Int` data types (#768)

* feat: update standard library

* Update comments

* Improve errors when no `failed` block used after failable expression (#769)

* feat: better handle failed block error

* feat: handle commands

* fix: clippy

* feat: add tests

* Update missing functions (#774)

* fix: nested arrays (#780)

* Introduce an intermediate state of texts between parsing and translating (#772)

* Introduce interpolated_region module

- literal text and command are parsed to a rust strings at first.

* stdlib: A negative offset must be separated from the colon

https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html

* Do not escape quote in command

* stdlib: Escape single \ in texts

* Add a command escaped test

* Remove unnecessary peekable()

* Surround raw string with `#`

* Re-add missed exclamation mark handling

* Implement to_char for InterpolatedRegionType

* Implement `succeeded` block for handling command and function success (#787)

* Initial plan

* Implement succeeded block feature with basic functionality

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Complete succeeded block implementation with comprehensive tests

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Clean up test files based on code review feedback

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Remove unused is_main field from Succeeded struct

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Add echo "Succeeded" to function_succeeded_fail test

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Shorten tests

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>
Co-authored-by: lens0021 <lorentz0021@gmail.com>

* Fix reversed ranges on Linux (#785)

* fix: reversed ranges

* fix: case of empty range

* fix: update tests

* docs(stdlib): Fix typos (#790)

* docs(stdlib): Fix typos

* docs: Fix more typos

* Delete build.ab (#793)

* docs: Exactly describe the current behaviors of std/array (#788)

* Document the failure of addar_extract_at

Removed at b6e57a8#diff-669cad100ed752df0476499d4b3752259de172ba6483c77c848b95765e3aa57c

* docs: array_remove_at returns Null always

* docs: Reflect the current behavior of array_last

* docs: array_pop fails if the array is empty

* chore!(stdlib): Make five stdlib functions failable instead of returning a bool (#791)

* Make four stdlib functions to failable instead of returning bool

* Make dir_create failable

* fix: Use globally unique id for the arguments of the main function (#796)

* fix: Use globally unique id for arguments of the main function

* Use local args

* Make array_first and array_shift failable when the array is empty (#789)

* Migrate tests bash calls to builtin (#794)

* Implement `sudo` command modifier (#782)

* Initial plan

* Implement sudo command modifier with detection logic and comprehensive tests

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix sudo modifier to use runtime detection instead of compile-time detection

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Refactor sudo implementation to use __sudo variable name and VarStmtFragment/VarExprFragment

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Simplify sudo detection to use concise bash logic and return just VarExprFragment

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Update sudo modifier error message for better consistency

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Clean up code by removing comments from gen_sudo_prefix function

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* feat: update grammar ebnf

* feat: properly test sudo

* fix: typo

* Remove else clause from chained modifiers sudo test as requested

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Simplify sudo test condition by removing root user check

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>
Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* feat(std/array): Add `array_filled` (#783)

* feat(std): array_filled

* Remove test for array_filled

* Add default value to `array_filled`

* Change description of `array_filled`

* Change comments to triple slash

* Apply suggestions from code review

Change type tests for stronger assertion.

Co-authored-by: Paweł Karaś <pkaras.it@gmail.com>

---------

Co-authored-by: Paweł Karaś <pkaras.it@gmail.com>

* [Feature] Add `then` block for handling command exit codes (#800)

* Initial plan

* Implement core then block functionality

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix then block tests and complete implementation

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Clean up imports and finalize then block implementation

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Address PR feedback: simplify conditions, use VarStmtFragment, optimize empty blocks

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Address all PR feedback: remove unused fields, use Type::Int, use variable function, wrap in context

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Final cleanup: remove unused comments, use VarStmtFragment builder pattern, improve error handling

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Remove unused set_position and set_function_name methods from Then struct

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Debug: Investigating __status variable issue in trust contexts

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix trust context regression and type consistency: use Type::Int for __status, return __status in empty blocks

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* WIP: Add lookahead for then( pattern to avoid ternary expression conflict - still debugging

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Revert WIP lookahead commit - back to working state before ternary conflict investigation

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* fix: then command modifier

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>
Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>

* Use recent syntax and stdlib in install.ab (#792)

* chore: Use latest sytax in install.ab

* Use new succeeded syntax

* dir_create() now failable

* Add parameter support to failed block for capturing exit codes (#806)

* Initial plan

* Add parameter support to failed block

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Improve error message for '?' operator usage (#805)

* Improve error message for '?' operator usage

* Update error messages to include operator '?'

* Fix error message for '?' operator usage

* Update src/modules/condition/failed.rs

Co-authored-by: Lens0021 / Leslie <lorentz0021@gmail.com>

* Update error message for failed function call

* Update documentation for failed command syntax

Clarify error message for failed commands in documentation.

* Fix error message for failed command handling

* Correct error message for failed command syntax

* Update error messages for failed command handling

* Fix error message for failed command syntax

Updated error message to include 'then' in command syntax.

---------

Co-authored-by: Lens0021 / Leslie <lorentz0021@gmail.com>

* Remove `__` prefix from variable and function names in generated Bash code (#804)

* Initial plan

* Implement new variable and function naming convention

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Update snapshot tests for new naming convention

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Address PR feedback: improve wording and calculate is_all_caps dynamically

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Centralize is_all_caps function in utils/mod.rs

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Add gen_variable_prefix method to TranslateMetadata and update usage

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Correct interpolation within single-quoted strings in commands (#808)

* Remove rotten TODOs (#809)

* Ignore double-quoted single quote when escaping (#814)

* Add more reserved words (#812)

* Add more reserved words

* `while`

* Remove __ prefix from args of the main function (#817)

* Stabilize single-quoted command interpolation (third fix) (#819)

* Add more quote escaping tests

* Fix single-quote balancing when rendering interpolated fragments

* chore: Remove unused variables

* Fix single-quote reopening for interpolated commands

* Add test which has single quoted multiple interpolates

---------

Co-authored-by: Codex [bot] <codex@users.noreply.github.com>

* Fix main args global id reuse in translation (#825)

Co-authored-by: Codex [bot] <codex@users.noreply.github.com>

* Revert "Add warning for invalid escape sequences in string literals (#732)" (#823)

* Revert "Add warning for invalid escape sequences in string literals (#732)"

* Remove a validate_text_escape_sequences call

* Separate type-checking from ParsingModule to new TypeCheckModule trait (#770)

* Initial plan

* Implement TypeCheckModule trait and update BinOp, UnOp, TypeOp implementations

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Complete TypeCheckModule implementation for shorthand operations

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Add type checking phase to compiler and implement TypeCheckModule for core syntax modules

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix clippy errors and warnings

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix recursive type checking in nested syntax modules

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Address minor issues: move type checks, remove comments, fix imports, add test

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Simplify match statement in fail.rs and move comments to top in test file

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix missing recursive typecheck calls in binop, unop, and typeop operators

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Move type assignments from parse phase to typecheck phase

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Move handle_variable_reference calls to typecheck phase and fix array literal defaults

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Store token positions in module structures and remove moved-code comments

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Remove unnecessary Option::is_some() checks in typecheck implementations

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix variable reference handling by moving VariableGet logic to typecheck phase

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Fix compilation errors in VariableGet by adding missing tok field

Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>

* Minor formatting

* Print the array type state in an error message

* fix: update types after typecheck

* feat: refactor functions

* feat: fix variables and arrays

* fix: loops

* feat: finish typecheck transition

* feat: resolve clippy errors

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>
Co-authored-by: Paweł Karaś <pkaras.it@gmail.com>
Co-authored-by: lens0021 <lorentz0021@gmail.com>

* Added improvements to stdlib (#821)

* Remove dbg call

* feat: update staging with keyword rename

* fix: Text cannot be casted at all (#832)

* fix: fail now proprely validates a variable (#836)

* Refactor `Statement` module (#839)

* feat: refactor statement

* fix: remove unused macros

* Function body is parsed when not called (#830)

* fix: function body is parsed when not called

* feat: add test

* Resolve issues with not covered warnings in tests (#841)

* feat: remove warnings

* feat: fix warnings

* fix: make sed_version work on BSD

* feat: update docs generator script dosc.ab

* Optimize docs gen usage examples for LSP (#843)

* feat: update standard library doc gen

* feat: update level for usage term

* feat: improve doc gen

* feat: bump amber version (#760)

* Release 0.5.0-alpha

---------

Co-authored-by: Lens0021 / Leslie <lorentz0021@gmail.com>
Co-authored-by: Huw Walters <huw.walters@gmail.com>
Co-authored-by: blek! <me@blek.codes>
Co-authored-by: Mohamed Magdi <mohamed.magdi@maxab.io>
Co-authored-by: Daniele Scasciafratte <mte90net@gmail.com>
Co-authored-by: Aleksana <alexander.huang.y@gmail.com>
Co-authored-by: Karim Vergnes <me@thesola.io>
Co-authored-by: Hubert Jabłoński <hubik080@gmail.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ph0enixKM <29208124+Ph0enixKM@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Rudy Mendoza <77073368+UrbanCoffee@users.noreply.github.com>
Co-authored-by: Codex [bot] <codex@users.noreply.github.com>
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.

[Feature] Ability to pass failure exit code to the failed block

3 participants