Thread overview
DMD: Is it possible change compile time errors to runtime errors in Dlang?
Mar 06, 2020
Marcone
Mar 06, 2020
Mathias Lang
Mar 06, 2020
Marcone
Mar 06, 2020
Ali Çehreli
Mar 06, 2020
Basile B.
March 06, 2020
Is it possible change compile time errors to runtime errors in Dlang?
If yes, how can I make it?
March 06, 2020
On Friday, 6 March 2020 at 04:56:28 UTC, Marcone wrote:
> Is it possible change compile time errors to runtime errors in Dlang?
> If yes, how can I make it?

No it's not possible, D is a statically typed language.
Why would you want errors that can be caught at compile time to happen at runtimes ?
March 06, 2020
On Friday, 6 March 2020 at 05:31:57 UTC, Mathias Lang wrote:
> On Friday, 6 March 2020 at 04:56:28 UTC, Marcone wrote:
>> Is it possible change compile time errors to runtime errors in Dlang?
>> If yes, how can I make it?
>
> No it's not possible, D is a statically typed language.
> Why would you want errors that can be caught at compile time to happen at runtimes ?

I'm coming from Python
March 06, 2020
On 3/6/20 8:59 AM, Marcone wrote:
> On Friday, 6 March 2020 at 05:31:57 UTC, Mathias Lang wrote:
>> On Friday, 6 March 2020 at 04:56:28 UTC, Marcone wrote:
>>> Is it possible change compile time errors to runtime errors in Dlang?
>>> If yes, how can I make it?
>>
>> No it's not possible, D is a statically typed language.
>> Why would you want errors that can be caught at compile time to happen at runtimes ?
> 
> I'm coming from Python

Perhaps you can share an example of your trouble, and we can explain why it's better to have compiler errors in that case.

-Steve
March 06, 2020
On Friday, 6 March 2020 at 04:56:28 UTC, Marcone wrote:
> Is it possible change compile time errors to runtime errors in Dlang?

no

> If yes, how can I make it?

if you deactivate all the errors emitted during the semantic then there are very good chance that the compiler crashes while generating code.
March 06, 2020
On 3/6/20 5:59 AM, Marcone wrote:> On Friday, 6 March 2020 at 05:31:57 UTC, Mathias Lang wrote:

> I'm coming from Python

The fact that errors are delayed until run time is a Python deficiency. We accept that deficiency because we also accept claimed benefits that Python brings.

If you want to skip the compilation step, you unfortunately can not, but you can combine compilation and execution steps with 'rdmd', which may make it look like the errors are caught at run time:

  https://dlang.org/rdmd.html

Ali