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

const is not recognised as keyword #8

Closed
HaSa1002 opened this issue Oct 30, 2020 · 0 comments · Fixed by #16
Closed

const is not recognised as keyword #8

HaSa1002 opened this issue Oct 30, 2020 · 0 comments · Fixed by #16
Labels
bug Something isn't working converter:csharp

Comments

@HaSa1002
Copy link
Owner

Version: 0.7-dev (Last Build 2020-09-13 01:30)

Description of the problem:
const is not recognised as keyword
Steps to reproduce:
See below
Code:

Source Code
const MAX_15B = 1 << 15
const MAX_16B = 1 << 16

func unsigned16_to_signed(unsigned):
    return (unsigned   MAX_15B) % MAX_16B - MAX_15B

func _ready():
    var f = File.new()
    f.open(user://file.dat, File.WRITE_READ)
    f.store_16(-42) # This wraps around and stores 65494 (2^16 - 42).
    f.store_16(121) # In bounds, will store 121.
    f.seek(0) # Go back to start to read the stored value.
    var read1 = f.get_16() # 65494
    var read2 = f.get_16() # 121
    var converted1 = unsigned16_to_signed(read1) # -42
    var converted2 = unsigned16_to_signed(read2) # 121
Output
[codeblocks]
[gdscript]
const MAX_15B = 1 << 15
const MAX_16B = 1 << 16

func unsigned16_to_signed(unsigned):
    return (unsigned   MAX_15B) % MAX_16B - MAX_15B

func _ready():
    var f = File.new()
    f.open(user://file.dat, File.WRITE_READ)
    f.store_16(-42) # This wraps around and stores 65494 (2^16 - 42).
    f.store_16(121) # In bounds, will store 121.
    f.seek(0) # Go back to start to read the stored value.
    var read1 = f.get_16() # 65494
    var read2 = f.get_16() # 121
    var converted1 = unsigned16_to_signed(read1) # -42
    var converted2 = unsigned16_to_signed(read2) # 121
[/gdscript]
[csharp]
Const Max15b = 1 <  < 15;
Const Max16b = 1 <  < 16;

public void Unsigned16ToSigned(?TYPE? unsigned)
{
    return (unsigned   MAX_15B)% MAX_16B - MAX_15B;
}

public override void _Ready()
{
    var f = new File();
    f.Open(user://file.dat, File.WRITE_READ);
    f.Store16() - 42); // This wraps around and stores 65494 (2^16 - 42).
    f.Store16(121); // In bounds, will store 121.
    f.Seek(0); // Go back to start to read the stored value.
    ?VAR? read1 = f.Get16(); // 65494
    ?VAR? read2 = f.Get16(); // 121
    ?VAR? converted1 = Unsigned16ToSigned(read1); // -42
    ?VAR? converted2 = Unsigned16ToSigned(read2); // 121
}
[/csharp]
[/codeblocks]
Expected Output
Warnings
[4] No return value provided. Assuming void. Use -> RETVAL to specify
[4] No type provided. Consider type hinting with NAME:TYPE
[5] If constant is enum refer to documentation for correct syntax.
[5] If constant is enum refer to documentation for correct syntax.
[5] If constant is enum refer to documentation for correct syntax.
[7] No return value provided. Assuming void. Use -> RETVAL to specify
[9] If constant is enum refer to documentation for correct syntax.
[10] If constant is enum refer to documentation for correct syntax.
[13] Type of declaration is unknown
[14] Type of declaration is unknown
[15] Type of declaration is unknown
[16] Type of declaration is unknown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working converter:csharp
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant