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

Nullable array argument can't be strong checking on equals to NULL #1094

Closed
kse300489 opened this issue Sep 26, 2015 · 1 comment · Fixed by #2211
Closed

Nullable array argument can't be strong checking on equals to NULL #1094

kse300489 opened this issue Sep 26, 2015 · 1 comment · Fixed by #2211
Assignees
Labels
Milestone

Comments

@kse300489
Copy link

kse300489 commented Sep 26, 2015

On 0.8 version of zephir strong type checking on NULL not working with nullable array argument.

Example:

public function simpleMethod(const array items = NULL){
  bool
    isItemsNULL;

  let
    isItemsNULL = NULL === items;
  // generate error: Unknown type: array in %file% on line %line%
  let
    isItemsNULL = items === NULL;
  // this code, generate the folowong C code:
  // ...
  // zephir_get_arrval(items, items_param); // <-- this is error, becouse array can be NULL, but zephir_get_arrval convert NULL to empty array
  // ZEPHIR_CHECK_POINTER(items);
  // isItemsNULL = ZEPHIR_IS_STRING_IDENTICAL(items, ""); // <-- WTF oO? Why string? I try to check is 'items' equal to NULL, not to empty string
  let
    isItemsNULL = is_null(items); // <-- this code works, and generates the correct code
  // isItemsNULL = Z_TYPE_P(items) == IS_NULL;
}

In all three cases zephir must generate the same code:

isItemsNULL = Z_TYPE_P(items) == IS_NULL;
@steffengy steffengy added the bug label Nov 6, 2015
@danhunsaker danhunsaker added this to Needs triage in Zephir Bugs Dec 12, 2018
@sergeyklay sergeyklay moved this from Needs triage to High priority in Zephir Bugs Mar 10, 2019
@sergeyklay sergeyklay self-assigned this Mar 10, 2019
@sergeyklay sergeyklay removed their assignment Sep 7, 2020
@niden niden removed this from High priority in Zephir Bugs Feb 16, 2021
@Jeckerson
Copy link
Member

This syntax doesn't exists in Zephir:

let
    isItemsNULL = NULL === items;

It must be reversed.

@Jeckerson Jeckerson added this to the 0.13.x milestone Apr 12, 2021
Jeckerson added a commit that referenced this issue Apr 12, 2021
@Jeckerson Jeckerson linked a pull request Apr 12, 2021 that will close this issue
3 tasks
Jeckerson added a commit that referenced this issue Apr 15, 2021
Jeckerson added a commit that referenced this issue Apr 15, 2021
@Jeckerson Jeckerson modified the milestones: 0.13.x, 0.13.3 Apr 15, 2021
@Jeckerson Jeckerson self-assigned this Apr 15, 2021
@Jeckerson Jeckerson mentioned this issue Apr 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants