Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • vala vala
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 769
    • Issues 769
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 75
    • Merge requests 75
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • valavala
  • Issues
  • #942
Closed
Open
Issue created Mar 21, 2020 by Emill@Emill

Inconsistent array declarations and definitions should lead to a warning or error

Currently a variety of combinations of array declarations are accepted while parts are silently ignored or overruled.

The Vala code:

void main() {
    int[10] arr = {1};
    stdout.printf("Length: %d\n", arr.length);
}

doesn't give any compilation error. C code:

void
_vala_main (void)
{
	gint* arr = NULL;
	gint* _tmp0_;
	gint arr_length1;
	gint _arr_size_;
	FILE* _tmp1_;
	_tmp0_ = g_new0 (gint, 1);
	_tmp0_[0] = 1;
	arr = _tmp0_;
	arr_length1 = 1;
	_arr_size_ = arr_length1;
	_tmp1_ = stdout;
	fprintf (_tmp1_, "Length: %d\n", arr_length1);
	arr = (g_free (arr), NULL);
}

Using a size in that context shouldn't be allowed.

Trying to declare a function which takes an array as a parameter with the same type declaration:

void func(int[10] arr) {
}

however correctly results in a reasonable error message "syntax error, no expression allowed between array brackets" (for some reason the error message is duplicated).

Edited Mar 22, 2020 by Rico Tzschichholz
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking