Thanks to visit codestin.com
Credit goes to github.com

Skip to content

int val = some_int + some_distinct_inline_int errors that int cannot be cast to DistinctInt #2468

@Book-reader

Description

@Book-reader
typedef DistinctInt = inline int;
fn int main()
{
  int a = 1;
  DistinctInt b = 2;
  int c = a + b; //  Error: Implicitly casting 'int' to 'DistinctInt' is not permitted, but you may do an explicit cast by placing '(DistinctInt)' before the expression.
  return 0;
}

it seems like b should be automatically converted to an int, or at least that the error message should say to cast b to an int since the expression is being assigned to another int.

I remember there being some issues with operators and typedef inline, is this a situation where an operator should be defined explicitly?

Metadata

Metadata

Assignees

Labels

BugSomething isn't workingFixed needs testingNeeds verification / testing that it now works

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions