Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Fix object.__ArrayCast error message generation so it works with CTFE #2531

Merged
merged 1 commit into from
Mar 31, 2019
Merged

Fix object.__ArrayCast error message generation so it works with CTFE #2531

merged 1 commit into from
Mar 31, 2019

Conversation

JinShil
Copy link
Contributor

@JinShil JinShil commented Mar 30, 2019

This is a followup to #2264

It is intended to resolve an error currently being encountered on the DMD side in dlang/dmd#9516

Error: `alloca` cannot be interpreted at compile time, because it has no available source code

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @JinShil! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + druntime#2531"

Copy link
Contributor

@thewilsonator thewilsonator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM.

@jacob-carlborg
Copy link
Contributor

alloca cannot be made into a template to have the source code available. Or won’t that help?

@thewilsonator
Copy link
Contributor

Its a compiler intrinsic most of the time, I've no idea why or how its part of druntime.

@jacob-carlborg
Copy link
Contributor

https://github.com/dlang/druntime/blob/master/src/rt/alloca.d

I guess inline assembly doesn’t work at compile time.

@JinShil
Copy link
Contributor Author

JinShil commented Mar 30, 2019

See

* This is a 'magic' function that needs help from the compiler to

It's a magic function, given special treatment by the compiler. It is unlike any other and requires compiler assistance to work properly.

@JinShil
Copy link
Contributor Author

JinShil commented Mar 30, 2019

Test suite is printing something like this in DMD...

/home/mike/github/JinShil/druntime/import/object.d(4772): Error: `['A', 'n', ' ', 'a', 'r', 'r', 'a', 'y', ' ', 'o', 'f', ' ', 's', 'i', 'z', 'e', ' ', '8', ' ', 'd', 'o', 'e', 's', ' ', 'n', 'o', 't', ' ', 'a', 'l', 'i', 'g', 'n', ' ', 'o', 'n', ' ', 'a', 'n', ' ', 'a', 'r', 'r', 'a', 'y', ' ', 'o', 'f', ' ', 's', 'i', 'z', 'e', ' ', '0', ',', ' ', 's', 'o', ' ', '`', 't', 'y', 'p', 'e', 'o', 'f', '(', 'n', 'u', 'l', 'l', ')', '`', ' ', 'c', 'a', 'n', 'n', 'o', 't', ' ', 'b', 'e', ' ', 'c', 'a', 's', 't', ' ', 't', 'o', ' ', '`', 's', 't', 'r', 'i', 'n', 'g', '`', '\x00', '\xff', '\xff', '\xff',

It seems to work fine at run.dlang.org, though: https://run.dlang.io/is/5a6tje

How do I get it to render as a normal string? Beware, we are already casting an array, when we're in this function, so I don't think cast(string)msg would be wise.

@jacob-carlborg
Copy link
Contributor

I’ve seen the same thing with failing static asserts

@JinShil
Copy link
Contributor Author

JinShil commented Mar 30, 2019

Yep, looks like CTFE string rendering has a problem: https://run.dlang.io/ (Sigh, I guess I need to figure out how to fix that too).

@jacob-carlborg
Copy link
Contributor

Regression?

@JinShil
Copy link
Contributor Author

JinShil commented Mar 30, 2019

Regression?

No, it appears to have been that way since ancient times. I may address it in a new PR, if it ends up blocking the DMD PR.

I think this is ready to go, but I think the DMD side requires some more work. At least it will allow me to continue with the DMD PR. If additional fixes are needed, I can submit them in followup PRs.

@dlang-bot dlang-bot merged commit cad29f9 into dlang:master Mar 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants