Repository navigation
Accessing an array out of bounds, should generates an exception like on .NET - #3748
Conversation
|
Oups I didn't test TypeScript locally, I will have a look at it. |
315c251 to
357b96c
Compare
|
Failing test is this one: Fable/tests/Js/Main/MiscTests.fs Lines 491 to 499 in 53238bc Failing on this line Should we provide the generic type to Also this tests is kind of really specific because it is using a TypeProviders, so perhaps we should disable it or adapt the TypeProvider if needed. I think that for now, we should probably disable the test and create an issue to keep track of it. If the same problem occurs in other situations. |
|
@MangelMaxime Yes, it's strange, it should probably run for JS too. |
|
@MangelMaxime Also, on an unrelated note, recently we tend to merge a lot of commits with every PR. |
Generated code looks like this: testCase("Fable.JsonProvider works", (): void => {
const parsed: any = JSON.parse(ANOTHER_JSON);
equal<boolean>(false, (parsed["widget"])["debug"]);
equal<string>("lots of", ((parsed["widget"])["text"])["data"]);
equal<float64>(80, item(1, ((parsed["widget"])["text"])["size"])["height"]);
equal<float64>(500, ((parsed["widget"])["text"])["vOffset"]);
})
Noted, I agree and it will avoid commits like |
|
How about setters? let x = [| "0" |]
x[5] <- "0"
printfn $"{x.Length}"
printfn $"{x[2]}" |
|
I didn't think about it. I will also have a look at the setter code. |
357b96c to
6d7df02
Compare
|
I managed to add the fix for For the second one, I add to unwrap |
| // system. We suppose this is probably due to the TypeProvider generation | ||
| // so for now we just ignore that situation hoping this is not | ||
| // indicative of other potential issues like this | ||
| // See: https://github.com/fable-compiler/Fable/pull/3748 |
There was a problem hiding this comment.
@MangelMaxime Looks like that test is failing for JS too
There was a problem hiding this comment.
This seems to be because I forgot to update the compiler directive for the open statement.
I have it working locally now, let's hope this is the final CI run and we can merge this PR.
There was a problem hiding this comment.
Looks like not, the test was disable for JavaScript because when testing using fable-standalone we don't support TypeProviders.
But ok, that's not related to my PR changes will fix it with an additional compiler directive.
| } | ||
|
|
||
| #if !FABLE_COMPILER_TYPESCRIPT | ||
| #if FABLE_COMPILER && !FABLE_COMPILER_TYPESCRIPT && !NPM_PACKAGE_FABLE_COMPILER_JAVASCRIPT |
There was a problem hiding this comment.
@MangelMaxime I wonder if we can simplify this to be just:
#if !FABLE_COMPILERinstead of introducing yet another define:
#if FABLE_COMPILER && !FABLE_COMPILER_TYPESCRIPT && !NPM_PACKAGE_FABLE_COMPILER_JAVASCRIPTI understand why we need this test to run on JS/TS, but it's an example of a test that has a dependency on an external assembly.
Perhaps this test can be moved to the integration tests, or somewhere else.
Fix #3729
@ncave Could you please have a look at what I did?
By some trial and error, I found that these places are where we handle array index access +
Array.itemwhich have the same behaviour.