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

typedef does not handle constructors correctly #408

Open
charlesstaats opened this issue Dec 26, 2023 · 0 comments
Open

typedef does not handle constructors correctly #408

charlesstaats opened this issue Dec 26, 2023 · 0 comments
Assignees
Labels

Comments

@charlesstaats
Copy link
Contributor

For example, there is a struct in three.asy called Render that has a void operator init() constructor in which all parameters have default values. Thus,

import three;
render();

runs successfully without error. However, if we then do

typedef render Render;
Render();

an error results.

For completeness, here's what I actually ran in interactive mode to test this (the only line that produced an error was Render()):

> import three
> render()
> typedef render Render;
> Render()
-: 1.1: no matching variable 'Render'
> Render f() { return render(); }
> f()  // no error for returning something of type Render
> 

As a side note, it might make sense for typedef to duplicate the names of functions whose name is the same as the return type, whether or not those functions are constructors. For instance, it might make sense for the following code

struct a { int x; }

a a(int x) {
  a retv = new a;
  retv.x = x;
  return retv;
}

typedef a b;

to include syntactic sugar for something like b b(int) = a;.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants