42School / norminette

Official 42 norminette
MIT License
972 stars 141 forks source link

Error: Declaration and assignation on a single line #350

Open mjy9088 opened 2 years ago

mjy9088 commented 2 years ago

Describe the bug

Incorrect error: Error: Declaration and assignation on a single line

Erroneous code

/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ftc__at_quick_exit.c                               :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: Juyeong Maing <jmaing@student.42seoul.kr>  +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2022/09/23 00:01:39 by Juyeong Maing     #+#    #+#             */
/*   Updated: 2022/09/23 00:20:04 by Juyeong Maing    ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "ftc__stdlib.h"

#include <stdbool.h>

#include "ftc__internal_global.h"
#include "ftc__string.h"

static bool increase_handler_array(void)
{
    void (**const   new_handler_array)(void)
        = ftc__malloc(
            sizeof(void (*)(void))
            * g()->ftc.quick_exit.bonus_handler_capacity * 2);

    // ...
}

// ...

Additional infos

mjy@192 c % uname -a
Darwin 192.168.nate.com 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101 arm64
mjy@192 c % python --version
zsh: command not found: python
mjy@192 c % python3 --version
Python 3.10.6
mjy@192 c % norminette --version
norminette 3.3.51
mjy@192 c % 

Additional context

incorrect:

static bool increase_handler_array(void)
{
    void (**const   new_handler_array)(void) // tab
        = ftc__malloc(
            sizeof(void (*)(void))
            * g()->ftc.quick_exit.bonus_handler_capacity * 2);

correct:

static bool increase_handler_array(void)
{
    void (**const new_handler_array)(void) // space
        = ftc__malloc(
            sizeof(void (*)(void))
            * g()->ftc.quick_exit.bonus_handler_capacity * 2);
matthieu42Network commented 1 year ago

Hello,

void (**const   new_handler_array)(void)
        = ftc__malloc(
            sizeof(void (*)(void))
            * g()->ftc.quick_exit.bonus_handler_capacity * 2);

is indeed a declaration and an assignation.

mjy9088 commented 1 year ago

@matthieu42Network This should not be an error because it is a declaration and assignment to a const variable.

matthieu42Network commented 1 year ago

hello I didn't see the const