This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[PATCH antimony v2] c: use correct type in array generation

Message ID
DKIM signature
Download raw message
Patch: +3 -3
Earlier, to generate the array, we're calling generate_type on the type
that came to this function which *IS* an array. That creates an infinite
loop and thus causing a stack overflow.

The fix is simple, use type that the array holds (e.g. Int) and not the
type of array itself (which is Array<Int> in this case).
 src/generator/c.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/generator/c.rs b/src/generator/c.rs
index 178de85..7d7618d 100644
--- a/src/generator/c.rs
+++ b/src/generator/c.rs
@@ -53,13 +53,13 @@ pub(super) fn generate_type(t: Either<Variable, Option<Type>>) -> String {
            Type::Any => "void *".into(),
            Type::Bool => "bool".into(),
            Type::Struct(_) => todo!(),
            Type::Array(_) => match name {
            Type::Array(t) => match name {
                Some(n) => format!(
                    "{T} {N}[]",
                    T = generate_type(Either::Right(Some(t))),
                    T = generate_type(Either::Right(Some(*t))),
                    N = n
                None => format!("{}[]", generate_type(Either::Right(Some(t)))),
                None => format!("{}[]", generate_type(Either::Right(Some(*t)))),
        None => "void".into(),

[antimony/patches/ci.yml] build failed

Message ID
<20210226064305.6308-1-yyp@disroot.org> (view parent)
DKIM signature
Download raw message
antimony/patches/ci.yml: FAILED in 2m18s

[c: use correct type in array generation][0] v2 from [Alexey Yerin][1]

[0]: https://lists.sr.ht/~garritfra/antimony/patches/20583
[1]: mailto:yyp@disroot.org

✗ #440222 FAILED antimony/patches/ci.yml https://builds.sr.ht/~garritfra/job/440222
Reply to thread Export thread (mbox)